How do I use fscanf to capture whitespace? For instance, I have this written on the file:
I want to store Arrow Smith as a string variable, but how do I do this?Code:Seat 30A Jack Arrow Smith
How do I use fscanf to capture whitespace? For instance, I have this written on the file:
I want to store Arrow Smith as a string variable, but how do I do this?Code:Seat 30A Jack Arrow Smith
You use fgets and spare yourself the headache of using fscanf.
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
fscanf with format specifier "%s"
or better
fgets + sscanf with format specifier "%s"
How do you use fgets to capture formatted strings?
For example, this seating information is among many others of the same type in the file. How do I store the strings for the first and last name while skipping over everything else?
EDIT: Never mind, I got it. I didn't realize the buffer size has to match the actual array.
Last edited by 843; 12-05-2010 at 01:20 PM.