#include <stdio.h>
int scanf(const char *format, ...);
int fscanf(FILE *stream, const char *format, ...);
int sscanf(const char *s, const char *format, ...);
int num;
scanf(“Hello %d”, &num);
#include <stdio.h>
main()
{
char s[256];
int n;
float f;
char c;
int scanf_count;
scanf_count = scanf("Hello, %d, %g, %c, %[^\n]",&n,&f,&c,s);
printf("%d\n",n);
printf("%g\n",f);
printf("%c\n",c);
printf("%s\n",s);
printf("scanf scaned result: %d\n", scanf_count);
return 0;
}
[root@localhost ~]# ./scanf.exe
Hello, 1234, 5.678, X, string to the end of the line #输入内容
1234
5.678
X
string to the end of the line
scanf scaned result: 4
[root@localhost ~]# ./scanf.exe
dfa #输入内容
0
0
scanf scaned result: 0
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |