J
jorntk
#include <stdio.h>
#include <string.h>
void strlines(char line[], char tokens[])
{
char * token_ptr, token[81];
token_ptr = strtok(line, " ");
while(token_ptr)
{
strcpy(token,token_ptr);
strcat(tokens, strcat(token, "\n"));
token_ptr=strtok(NULL, " ");
}
}
int main()
{
char sentence[81], words[81];
printf("enter a sentence: ");
fgets(sentence, sizeof sentence, stdin);
strlines(sentence,words);
puts(words);
}
why the above code display ,X @ at the beginning of the output?
#include <string.h>
void strlines(char line[], char tokens[])
{
char * token_ptr, token[81];
token_ptr = strtok(line, " ");
while(token_ptr)
{
strcpy(token,token_ptr);
strcat(tokens, strcat(token, "\n"));
token_ptr=strtok(NULL, " ");
}
}
int main()
{
char sentence[81], words[81];
printf("enter a sentence: ");
fgets(sentence, sizeof sentence, stdin);
strlines(sentence,words);
puts(words);
}
why the above code display ,X @ at the beginning of the output?