我正在编写代码来读写文本文件.但是当我运行我的代码时,我收到了一个SIGSEGV运行时错误.我需要帮助搞清楚代码有什么问题.
#include <stdio.h>
#include <stdlib.h>
int main(){
/*Variable for writing to file */
char *name[] = {"Raju", "Nayan", "Hanif"};
char *id[] = {"100", "101", "102"};
float cgpa[] = {3.50, 5.00, 4.00};
/*Variable for reading from file*/
char *getname, *getid;
float getcgpa;
int i;
FILE *fp;
fp = fopen("f:\\raju.nog", "w"); /*Create new file */
for(i=0; i<5; i++){
fprintf(fp, "%-10s%-10s%-1.2f\n", name[i], id[i], cgpa[i]); /*write to file*/
}
fclose(fp);
/*read from file and print to screen*/
fp = fopen("f:\\raju.nog", "r");
while(fscanf(fp, "%s %s …Run Code Online (Sandbox Code Playgroud)