S
Stu
I have the following "C" program, which works fine.
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int
main()
{
char *buffer = "1234 - 5678";
int n, from, to;
n = sscanf (buffer, "%d%*s%d", &from, &to);
printf ("n = %d from = %d, to = %d\n", n, from, to);
return (0);
}
When I change the vaule of buffer to char *buffer = "1234-5678"; (note
I removed the spaces between '-') I need to change my scanf() to
n = sscanf (buffer, "%d%*c%d", &from, &to); /*change from %s to %c */
Can somebody please provide me with one scanf() statement that can handle
both spaces and non spaces between my values. The man page on Solaris did not
provide me with much direction thats why I am posting my question here.
Thanks in advance to all that answer
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int
main()
{
char *buffer = "1234 - 5678";
int n, from, to;
n = sscanf (buffer, "%d%*s%d", &from, &to);
printf ("n = %d from = %d, to = %d\n", n, from, to);
return (0);
}
When I change the vaule of buffer to char *buffer = "1234-5678"; (note
I removed the spaces between '-') I need to change my scanf() to
n = sscanf (buffer, "%d%*c%d", &from, &to); /*change from %s to %c */
Can somebody please provide me with one scanf() statement that can handle
both spaces and non spaces between my values. The man page on Solaris did not
provide me with much direction thats why I am posting my question here.
Thanks in advance to all that answer