【发布时间】:2010-05-03 19:44:12
【问题描述】:
我正在使用 Plato3 编写 C 程序。
我正在创建一个菜单驱动程序,但想测试让它工作的基本概念
#include<stdio.h>
#include<ctype.h>
int function1();
main(){
char s;
do{
puts("\n choose the following");
puts("(P)rint\n");
puts("(Q)uit\n");
scanf("%c",&s);
s=toupper(s);
switch (s){
case 'P' : function1();
break;
case 'Q' : return -1;
break;
}
}while (function1()==0);
}
int function1(){
printf("Hello World");
return 0;
}
问题是一旦function1()返回值0,整个程序就回显了……为什么?
示例:运行程序给出了这个:
Hello WorldHellow World
choose the following
(P)rint
(Q)uit
Hello World
choose the following
(P)rint
(Q)uit
-- 知道为什么吗?
请帮忙,谢谢!!!!
【问题讨论】:
标签: c