I am doing some self-made exercises lately to practice my C skills.
One of them is something like this:
Given a file with something like: "Peter Wilson the swordsman".
I want to store "Peter Wilson" in the char array "name" and "swordsman" in char array "title".
So far I've tried this:
char name; fscanf(file," %s",name); char title; fscanf(file," the %s\n",title); printf("%s the %s",name,title);
The result is that it scans "Peter" into "name" and the rest is all garbled text. Is there anyway to make %s ignore whitespace?