Hi,
I am writing a program to accept a string from the user. But not able to print the whole sentence. Can get only first word -
Input - My name is Anthony
output- My
How can I print the whole sentence?
code -
I am writing a program to accept a string from the user. But not able to print the whole sentence. Can get only first word -
Input - My name is Anthony
output- My
How can I print the whole sentence?
code -
Code:
int main()
{
char* str;
str = (char*) malloc (sizeof(char)*256);
memset (str, 0, (sizeof(char)*256));
printf("Enter the string\n" );
scanf("%s", str);
printf("%s\n", str);
return 0;
}
Comment