Convert String to enum type

This is a discussion on Convert String to enum type within the C Programming forums, part of the General Programming Boards category; hello If i read a line from txt file and then i use the str token function to cut this ...

  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, 09:18 PM
  2. Replies: 8
    Last Post: 04-25-2008, 03: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, 05:33 PM
  5. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 04:58 PM

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