hi,
the error code was taken from msdn and it occured in my code as follows;
i am reading buffer from the file :
that's the code i have the run-time errors , i wonder you have some solutions,
respects;
RADAR
the error code was taken from msdn and it occured in my code as follows;
i am reading buffer from the file :
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
#define DSIZE 5
#define DEPTH 150
//LL structure
typedef struct node* NODE_PTR;
typedef struct node POOL;
struct node{
int dept;
int std_num;
char name[SIZE];
char lastname[SIZE];
double cgpa;
NODE_PTR link;
};
//--main method
int main(void)
{
NODE_PTR dept[DSIZE];//--departments will be sent to this header...
NODE_PTR temp;//--used for allocation of new nodes.
POOL swim[DEPTH];//--send students read from file to pool
int i = 0;//--counter for struct type swim.
//--reading from the file Faculty.txt:
FILE* fp;
char* file_name = "C:\\Faculty\\Faculty.txt";
//--open the file and Read it...
fp = fopen(file_name,"r+");
//--if there are problems while reading from the file:
if(fp == NULL)
{
printf("There are problems with file reading operations...\n"
"The program will exit immediately...\n");
exit(1);
}
//--no problems with reading from file , scan the components to the LL structure:
while(!feof(fp) && i < DEPTH)
{
//--node->ordered to be read:dept(int),
//--------std_num(int),name(charARR),lastname(charARR),cgpa(double)
fscanf(fp,"%d %d %s %s %lf",
&swim[i].dept,
&swim[i].std_num,
swim[i].name,
swim[i].lastname,
&swim[i].cgpa
);
i++;
}//--end of scanning the file
return 0;
}
respects;
RADAR
Comment