<分区>
我编写的程序太长,无法复制到此站点。但需要的内容将粘贴到网站中。
这是 switch 语句:
void enterName();
int adminChoice;
printf("\nEnter Numeric Choice: ");
scanf("%d", &adminChoice);
switch(adminChoice)
{
case(1):
{
enterName();
}
}
这是实际的功能:
void enterName()
{
FILE *fp = fopen("/home/matthew/Desktop/BBE.txt", "w");
if (fp == NULL)
{
printf("Error opening file!\n");
exit(1);
}
char comment[100];
printf("Enter, String\n");
fgets(comment, sizeof comment, stdin);
fputs(comment,fp);
}
程序会要求用户输入字符串。但是没有时间放入所需的字符串。它只是结束程序。