Hi all,
I have an processor fault while running my code..
The error happens when it reaches files part..
what is the reason of this??
The code
Code:
#include <stdio.h>
typedef struct info* infoptr;
struct info{
char* permission;
char* digit;
char* owner;
char* group;
long int* size;
char* mtime;
char* fname;
infoptr next;
};
void main(){
FILE* fp;
infoptr head;
fp = fopen("info.txt","r");
if( feof(fp))
head = NULL;
else{
infoptr temp_info1, temp_info2;
temp_info1 = new info;
head = temp_info1;
fscanf( fp, "%s", temp_info1->permission );
fscanf( fp, "%s", temp_info1->digit );
fscanf( fp, "%s", temp_info1->owner );
fscanf( fp, "%s", temp_info1->group );
fscanf( fp, "%ld", temp_info1->size );
fscanf( fp, "%s", temp_info1->mtime );
fscanf( fp, "%s", temp_info1->fname );
temp_info1->next = NULL;
while( !feof(fp) ){
temp_info2 = new info;
temp_info1->next = temp_info2;
temp_info1=temp_info2;
fscanf( fp, "%s", temp_info1->permission );
fscanf( fp, "%s", temp_info1->digit );
fscanf( fp, "%s", temp_info1->owner );
fscanf( fp, "%s", temp_info1->group );
fscanf( fp, "%ld", temp_info1->size );
fscanf( fp, "%s", temp_info1->mtime );
fscanf( fp, "%s", temp_info1->fname );
}
temp_info2->next = NULL;
} // end if
}//end main