#include <stdio.h>
#include <string.h>
void parse(char data[], char *command, char *key, char *val) {
sscanf(data, "%s %s %s", command, key, val);
}
int main() {
char buffer[1025], command[1025], key[1025], val[1025];
printf("Enter command: \n");
scanf("%s\n", buffer);
parse(buffer, command, key, val);
printf("%s\n", command);
printf("%s\n", key);
printf("%s\n", val);
return 0;
}
Why does this not work? I am parsing a buffer into 3 strings, but the only one that gets copied over is the command, for the key and the val I just get some odd output instead of what it should be.
This post has been edited by porky101: 23 June 2012 - 08:17 AM

New Topic/Question
Reply




MultiQuote




|