c - 2nd Call to strtok() returns null -
I am at the top of the loop in client file for client / server communication. I get user input (input) from client And I need to straddle in CMD and CMD 2 for the work of my IFS.
The user is said to be "find friend" (this is a good command for the program). Using the following code, CMD = "meet" (yay!), But CMD 2 = "(empty)"
input is a four input [30] CMD and CMD 2 letters start in four letters Are there.
A little help here? Thanks! More importantly, you need to read in the entire line, which is / * As long as the user exits from the program / (Cmdnum! = 7) {printf ("\ nPlease enter a command:"); Scanf ("% 30s", input); CMD = Strontok (Input, ""); Printf ("CMD:% s \ n", CMD); If (SRCMP (CMD, "mill") == 0} {cmi2 = strotok (zero, "\ 0"); Printf ("cmd2:% s \ n", CMD2); Pstatus = Print (CMD, Sokfad); If (pstatus == 1) {printf ("printing print \ n"); }} And if (strcmp (cmd, "put") == 0) ..... etc, etc. ....
scanf with
% s Do not do this. It closes in the first place instead, try
fgets But remember that it leaves the new line, so add it as a limit. #include
Comments
Post a Comment