[code] scanf("%s",str); //输入命令 if(strcmp(str,"dir")==0) Showdir(); else if(strlen(str)==0) printf("hahaa"); [/code] 我的本意是接受一个字符串的输入,如果什么都没有输入,直接回车则 打印hahaha,但是好像不行,无论你回多少次车,程序一直等待你输入, 请教高手如何解决阿??谢谢!!
前天晚上难得不加班,终于抽空把它从书上敲下来了。
大家需要的赶紧收藏一下。
[code]scanf 原型:
# include
请问怎么用scanf()函数提取整数数组?这样可以不? int arry[10]; scanf("%d", arry); 或者这样: int i, int arry[10], int buf; for(i=0; i<10; i++) { scanf("%d", buf); arry = buf; }
1 #include
起源:见下面的帖子 http://bbs3.chinaunix.net/thread-1394046-1-1.html 这次讨论 printf 和 scanf 的输入,输出格式串。 空间上的副本: http://hi.chinaunix.net/?uid-20563859-action-viewspace-itemid-33200 [ 本帖最后由 retuor 于 2009-3-15 13:42 编辑 ]
这是什么问题:
请看如下代码:
#include
sscanf 名称: sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: Int sscanf( string str, string fmt, mixed var1, mixed var2 ... ); int scanf( const char *format [,argument]... ); 说明: sscanf与scanf类似,都是用于输入的,只是后者以屏幕(stdin)为输入源,前者以固定字符串为输入源。 其中的format可以是一个或多个 {% [width] [{h | l | I64 | L}]type | ' ' | '\t' | '\n' | 非%符号} 注: 1、...