hi all
i just write a code that read a string from list
and when i run the program always give me that the name of file is not exists!
here is the code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define A 50
typedef struct Lab *ptr;
struct Lab{
char Title[A];
char Author[A];
char Subject[A];
long ISBN;
ptr next;
};
typedef ptr LIST;
typedef ptr Postion;
void ReadFromFile(l);
int main()
{
LIST l;
l=(LIST)malloc(sizeof(struct Lab));
l->next=NULL;
ReadFromFile(l);
return 0;
}
void ReadFromFile(LIST l){
char reading[50];
FILE*fin;
printf("Enter the name of file");
scanf("%s",reading);
fin=fopen(reading,"r");
if(fin == NULL){
printf("the file not exsit");
ReadFromFile(l);
}
else
printf("okey");
fclose(fin);
}