当前位置: 代码迷 >> C语言 >> 在VC中,换行不能。。。
  详细解决方案

在VC中,换行不能。。。

热度:145   发布时间:2008-02-13 14:53:42.0
在VC中,换行不能。。。
#include<stdio.h>
void main()
{   void input(int num1,char name1[20],float score1);
    int i;
    struct
    {int num;
     char name[20];
     float score;} student[2];
    printf("请依次输入学号、姓名、分数\n");
    for(i=0;i<2;i++)
    {scanf("%d %s %f",&student[i].num,student[i].name,&student[i].score);
     input(student[i].num,student[i].name,student[i].score);
     //位置1
    
}
}
void input(int num1,char name1[20],float score1)
{   printf("%d,%s,3.1%f",num1,name1,score1);//位置3
    //位置2
    FILE *fp;
    fp=fopen("d:\\学生登记表.txt","a+");
    fprintf(fp,"%d\t\t%s\t\t3.1%f\n",num1,name1,score1);
    }
我在位置1和位置2处分别添加printf("\n"),但是在调试过程中并没有起作用,光标并没有换行
在位置3的语句执行完后,光标就停留在那一行,不跳到下一行

[[it] 本帖最后由 有敌手 于 2008-2-13 15:13 编辑 [/it]]
搜索更多相关的解决方案: int  float  score  void  quot  

----------------解决方案--------------------------------------------------------
还有一个疑问就是,我在VC中有时候写了个程序,执行错了,改了下,然后再执行,仍然报错
然后保存文件,关掉VC,再开一次,就可以正常运行了,为啥?
----------------解决方案--------------------------------------------------------
试过了,可以啊,就是你的子函数里的FILE *fp;作为定义要调到该函数头;至于第二个问题,应该是没有重建,所以改了还是报错
----------------解决方案--------------------------------------------------------
  相关解决方案