| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
输入框不能停止结束,不知道原因,代码如下: 
 
#include <stdio.h> 
#include <stdlib.h> 
#define SIZE 4 
 
struct student 
{ 
        char name[10]; 
        int phone; 
        char addr[15]; 
}stu[SIZE]; 
 
void main() 
{ 
        int i; 
         
        printf("Please input the student's name phone and address: \n"); 
         
        for(i=0; i<SIZE; i++) 
        { 
                scanf("%s %d %s",&stu[i].name,&stu[i].phone,&stu[i].addr); 
        } 
         
        save(); 
        system("pause"); 
} 
 
 void save() 
{ 
        FILE *fp; 
        int i; 
         
        if(!(fp = fopen("student.txt","wb"))) 
        { 
                printf("Cannot find the file!\n"); 
                return; 
        } 
         
        for(i=0; i<SIZE; i++) 
        { 
                 
                if( fwrite(&stu[i],sizeof(struct student),1,fp) != 1) 
                { 
                        printf("File write error!\n"); 
                        fclose(fp); 
                } 
                                                 
        } 
                         
} 
 |   
 
 
 
 |