Thread: Convert String to enum type

  1. #1
    Registered User
    Join Date
    Feb 2008
    Location
    N?A
    Posts
    23

    Convert String to enum type

    hello
    If i read a line from txt file and then i use the str token function to cut this line
    into words,and those words should be sent to a function that receive only enum type:

    For example i did that:
    Code:
    typedef enum {Black,White,NoColor} Color;
    char * color;
    and then

    Code:
    color=strtok(line," \t" )
    But my function only get enum??

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    So write a StrToColor() function:
    Code:
    Color StrToColor( const char*  str ) { ... }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  5. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM