|

楼主 |
发表于 2005-1-2 15:34:59
|
显示全部楼层
我没看出是么区别来啊
这是我编的程序
- //s.c
- #include <stdio.h>
- int main()
- {
- char line[100];
- int v1,v2;
- #ifdef S
- scanf("%d%d", &v1, &v2);
- printf("%d\t%d\n",v1,v2);
- #else
- fgets(line, sizeof(line), stdin);
- sscanf(line, "%d%d", &v1, &v2);
- printf("%d\t%d\n",v1,v2);
- #endif
- return 0;
- }
复制代码
这是结果- [leo@leo test]$ gcc s.c -DS [color=Magenta]编译scanf#[/color]
- [leo@leo test]$ ./a.out
- 1 2
- 1 2
- [leo@leo test]$ gcc s.c [color=Magenta]#编译fgets+sscanf[/color]
- [leo@leo test]$ ./a.out
- 1 2
- 1 2
- [leo@leo test]$
复制代码
都挺正常的嘛 |
|