C++ File loading problem

Hello.
i have declared class"Map" with Fchar and Fint;
im just tring to read data from file and store them in Fchar and Fint
Is this code bellow good?
my file is located at: named:
C:\C++ Projects\Story of Jack\files file.txt
File contains: with space after Hello and 3.
Hello
3
my project file is at C:\C++ Projects\Story of Jack StoryOfJack
bool Map::OnLoad()
{
FILE* Filee;
Filee = fopen("./files/file.txt", "r");
if(Filee != NULL)
{
fscanf(Filee, "%s\n%d", Fchar, &Fint);
fclose(Filee);
return true;
}
else
{
return false;
}
}
BTW
When i load images/music: & file is located at:
C:\C++ Projects\Story of Jack\img icon.bmp
if((Icon = SDL_LoadBMP("./img/icon.bmp")) == NULL)
{
return false;
}
works.

Map::OnLoad() returns false each time runned... i have file at location requested... code error?
I dont understand why it wont load my file. i allowed administrator acces and still getting error.
thx on youre time.
Last edited on
Filee = fopen("./files/file.txt", "r"); make it
filee.open("file.txt");
also use cin/getline because it is standard c++ not c. when you want to close the file do
filee.close();when you declare the file the variable you reference is already a pointer to the file. there is no real need to make your own pointer. FILE* Filee;
for example
1
2
 std::ifstream myfile;
myfile.open(here.txt); //myfile now points to the beginning of the file here.txt 
Topic archived. No new replies allowed.