Thread: Detect "Exit" as first word

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Grab the first word with sscanf and use strcmp to see if it is what you want it to be.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    13
    Quote Originally Posted by quzah View Post
    Grab the first word with sscanf and use strcmp to see if it is what you want it to be.


    Quzah.
    thanks for the reply. I added the sscanf :
    Code:
    main ()
    {
    	char line [ MAX_LINE ] , * words [ MAX_WORDS ] , message [ MAX_LINE ];
    	int stop =0 , nwords =0; 
        int i; 
    	
    	while (1)
    	{
    		printf ( " Enter line:" );
    		if ( NULL == fgets ( line , MAX_LINE , stdin ))
    			return 0;
    		tokenize ( line , words ,& nwords );
    		sscanf(words, "cont", i);
    }
    }
    I'm not sure if i did it correctly, and how do i use strcmp to compare the words so that when "cont" is appeared as first word, tokenization will then take place?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc compile errors, HELP!
    By FalconGK81 in forum C Programming
    Replies: 11
    Last Post: 02-14-2011, 04:17 AM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 06:44 PM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM