i am writing a function for my game engine
that reads data from a file and sets it to variables
but its not setting the data from the file to the c
variable
dose anyone know why this is?
void load_btl(constchar* file){//under construction
FILE *fp = fopen(file, "r");
char c;//a place holder for characters
char caption[50];
char name[30];
char hp[3];//will convert to int later
char lvl[3];//will convert to int later
unsignedchar i = 0;
unsignedchar data_lvl = 0;
if(fp == NULL){perror("\nFailed To Load btl File\a");getchar();}
while(fscanf(fp, "%c", &c) != EOF){
if (c == 10){data_lvl++;}//10 is '\n' in ASCII
if (data_lvl == 0){c = name[i];}
elseif(data_lvl == 1){c == caption[i];}
elseif(data_lvl == 2){c == hp[i];}
elseif(data_lvl == 3){c == lvl[i];}
i++;
}
printf("%c", name[0]);//prints out random value each time run
fclose(fp);
}
file:
tom
Hello!
66
3
the reason the file is in that format is the first line is
the name of a enemy
2nd line is a caption
3rd line is hp
4th is lvl