-
sscanf() question
I am using sscanf() to parse a line with the date contained within. The semantics of the line is as follows:
Code:
Date: Tues, February 24th 2009
Now for my code I have:
Code:
sscanf(dummy, "Date: %s\n", date);
But when I execute this instead of obtaining "Tues, February 24th 2009" I am only getting "Tues".
How would I go about fixing this issue. Thanks!
-
-
Thank you once again tabstop :) A little reading on the ole man page after you pointed that out and I found a solution to the problem. One more quick question is relating to an error I am getting when I compile with the -pedantic open enabled:
Code:
if((pRet = popen("ps -el", "r")) == NULL) {
fprintf(stderr, "ERROR: File pointer returned a Null value\n");
fprintf(stderr, "ERRNO = %s\n", strerror(errno));
exit(1);
}
http.c:275: warning: implicit declaration of function ‘popen’
http.c:275: warning: assignment makes pointer from integer without a cast
But I have the pret declared as a FILE * to hold the return value from popen?
-
You need to include the header that contains popen.
-
I double checked the manpage and double checked to make sure <stdio.h> is included but I am still receiving the warning
-
> I am getting when I compile with the -pedantic open enabled:
popen isn't an ANSI function, so it isn't prototyped when -pedantic is in effect.
-
Is there a way then to stop receiving this warning or do I just have to disabled -pedantic and/or ignore?
-
You're apparently targeting POSIX-like systems, so you can tell your implementation that by defining the _XOPEN_SOURCE macro to a suitable value. I'd recommend 600, which means SuSv3. You'd probably want to do this via the command-line, along the lines of:
Code:
gcc -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600
For the older, but still-has-everything-you-need-probably SuSv2:
Code:
gcc -Wall -std=c89 -pedantic -D_XOPEN_SOURCE=500