Well, this is the main question, but I seem to be pretty confused.
#include<stdio.h>
int main()
{
char a[100];
printf("Enter a string\n");
scanf("%s",a);
}
Basically, this is what I want to achieve. If I enter a line
James Bond
then I want this to be stored in array a. But the problem is that only the words of James are stored in the empty space between the letters. So how can I solve this problem.
UPDATE
After the answers below, I understand that fgets () would be a better choice. I want to know the inner workings of fgets, why it can store a string with a space where scanf cannot do the same.
source
share