I'm trying to read in a file that contains multiple lines of the form:
www.someurl.com,timestamp
I am using the following code:
char url[256];
unsigned int timestamp;
// Read each line from the input file.
while(fscanf(inputfile, "%s,%d", url, ×tamp) == 2) {
printf("%s was visited at %d\n", url, timestamp);
}
However, fscanf
scans the entire line into the string, and does not scan the timestamp into the integer. I'm sure this is a very basic mistake, but I can't figure it out. Could someone please explain why this is, and how I can go about fixing it?