Checking to see if the input has all of the compare line

This is a discussion on Checking to see if the input has all of the compare line within the C++ Programming forums, part of the General Programming Boards category; Here's the source, how can I use the same functions and everything to check for the entire line of the ...

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Checking to see if the input has all of the compare line

    Here's the source, how can I use the same functions and everything to check for the entire line of the compare instead of just one word. Also, how can I get it to have one word files... This is getting really crapped up.

    -This is where the string search problem is, I don't know what's wrong with the crapped up part, I think their all involved.
    Code:
    void cortana::find_line()
    {
    	linenumber=0;
    	ifstream check_in("compare.txt");
    	while(linenumber!=40)
    	{
    		getline(check_in,str,'\n');
    		str=lower(str);
    		if(strstr(str.c_str(),input.c_str()))
    		{
    			line=linenumber;
    			prep=true;
    			cortana::find_responce();
    			break;
    		}
    		else if(str=="")
    		{
    			prep=false;
    			cortana::find_responce();
    			break;
    		}
    		else if(input!=str)
    		{
    			linenumber++;
    		}
    	}
    	check_in.close();
    }
    
    void cortana::find_responce()
    {
    	cout << line;
    	getch();
    	linenumber=0;
    	ifstream check_out("responce.txt");
    	if(prep==true)
    	{
    		while(linenumber!=line+1)
    		{
    			getline(check_out,str,'\n');
    			if(linenumber==line)
    			{
    				responce=str;
    				break;
    			}
    			else
    			{
    				linenumber++;
    			}
    		}
    	}
    	else if(prep==false)
    	{
    		responce="I don't understand.";
    	}
    	check_out.close();
    }
    Last edited by drdroid; 03-01-2003 at 08:33 PM.

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Shouldn't you reverse the order of the arguments to strstr()?

    strstr( text , textToSearchFor )
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    yup...

    but now i don't get multi-word answers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  2. Checking for flag input through argv
    By cisokay in forum C Programming
    Replies: 6
    Last Post: 05-11-2005, 11:51 AM
  3. How to Input without Breaking line in a console?
    By Aidman in forum C++ Programming
    Replies: 11
    Last Post: 03-12-2003, 11:55 AM
  4. Checking input
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-10-2002, 10:00 AM
  5. input checking
    By kiki in forum C Programming
    Replies: 1
    Last Post: 01-28-2002, 04:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21