Hello,
In the program I'm working on, I need to read in lines from stdin. Lines like this:
Name 1 Name2 3
What I want to do is tokenize the line. However, when I do this, it makes each token a char*, right? How do I make the 1 and 3 in the line into an int? Here is what I'm trying now, but I don't think it's right:
Does the casting for score1 and score2 actually change the char* into an int? Thanks for the help.Code:while( fgets(buf,BUFSIZ,stdin) ) { team1 = strtok(buf," "); score1 = (int)strtok(NULL," "); team2 = strtok(NULL," "); score2 = (int)strtok(NULL,"\n");