0

So i have a program which reads the input out of a specific .txt file. The code is:

void Image::get_image_dimensions(char *fname)
{
// determine the number of entries in image
ifstream fin(fname);
fin >> num_rows ;
fin >> num_columns ;
cout << "...reading from file " << fname << endl;
cout << "File has " << num_columns << " rows and "<<  num_columns << " columns" << endl;
fin.close();

}

the method is called inside the main. After I compile the program with VS2010 and run the code everything works properly. But after if I go to the Debug folder of my program and run my program from there it doesn't read the input anymore, and crashes...

What might be the problem?

1 Answer 1

1

The current directory is different in the two cases. The best solution is to provide the full path to the file, not just the file name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.