reading strings into more than 1 array with if

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pb1uk
    New Member
    • Aug 2006
    • 5

    reading strings into more than 1 array with if

    hello, i need to read in commands from a text file. Once the first line is read into an array if it is a certain word then a certain amount of numbers are read into another array. i have been using

    filein>>array[size];
    if(command =="MOVETO")
    { filein>>value1[];
    filein>>value2[];
    }
    etc

    it doesnt seem to want to work and the compiler does like my use of == but i dont know why?!??!
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    What type is command?

    Assuming that it is an array of characters

    char command[50];

    The the compiler wont be able to copy with

    if ( command == "MOVETO" )

    because there is no intrinsic comparison of arrays or any complex structure.

    Look up and use the function

    strcmp or strncmp

    Comment

    Working...