Thread: string tokens

  1. #1
    Unregistered
    Guest

    string tokens

    IS there anyway to string tokens (identifiers) from a file without using strtok. I understand I could use else if token == "{" but I can't get my program to recognize the actual identifier token ..

    Help please ....

    or point me int he direction where ic an get help

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Post some code!

    What you want to do (a brief explanation) is just to got through the file with fgets or getting the chars separately and analyze them with if/else, or switch, statements.

    --Garfield
    1978 Silver Anniversary Corvette

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    To compare strings use strcmp() not == "{"
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Yes, Stoned_Coder is right. If you do:
    Code:
    char *string1, *string2;
    
    // initialize the strings
    
    if (string1 == string2)
    /*** ETC. ***/
    then (unless you set the address of string2 equal to the address of string1) it will be false. Becuase, this evaluates the addresses, not the characters like you are thinking.

    --Garfield
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM