class does not a name type error

Pages: 12
It needs to be in the same folder as your executable (or, strictly, where you were running it from). Why have you put it in the doc subfolder? How would your program know where that was?

In your code:
ifstream dosyaOku("okul.txt", ios::in);
This says that it is expecting to find the file okul.txt in the folder from which you launched the program.

From the background of the left-hand image in your picture, this program is being launched from a command window in folder
C:\users\Ihalit\Desktop\odev

So THAT is where it expects to find okul.txt.

NOT in some "doc" subfolder.



EITHER:

(1) Move okul.txt into the same folder as your executable derle.exe and launch from this folder by simply typing derle.exe (or, even, just derle) or in Windows explorer just double-click derle.exe.

OR:

(2) Navigate within your command window to the doc subfolder. Just type:
cd doc
Then launch the program by typing the correct relative path (here, .., for "up one directory"):
..\derle.exe

OR:

(3) Navigate within your command window to the doc subfolder (as above), then copy derle.exe into that subfolder, then launch derle.exe from within the doc subfolder itself.

Personally, I would work entirely in the command window and do (1).
Last edited on
Path, path, path. Everything is a file and every filename is a path.

A path can be absolute or relative.

Absolute path lists every directory from the root to final name. For example: "C:/Users/snafu/docs/fubar.txt"

Current working directory + relative path forms absolute path.

For example:
Current working directory is /home/snafu/porn
1
2
3
4
5
bar.open( "../docs/fubar.txt" );
// effectively calls:
bar.open( "/home/snafu/porn/../docs/fubar.txt" );
// i.e.
bar.open( "/home/snafu/docs/fubar.txt" );


In other words, if you want bar.open( "fubar.txt" ); to succeed, you have to run the program in the directory, where the file fubar.txt is (or have file fubar.txt in the directory, where you run the program). (Or use symlinks. Symlinks are a filesystem version of pointers.)

GUI's supposedly let one specify current working directory for a program.
a few likely mistakes:

- the file does not exist where you tried to open it. Its either in another folder or may not exist at all. Eg your program deletes it and then writes a new version, but only got to the delete part before crashing last run, that sort of thing.

- the file is locked open by a previous (possibly dead) run of your program or another tool (looking at with some editors while trying to open it with your program won't always work). Some OS can glitch and leave a file locked even if the program touching it is closed; some versions of windows needed a third party tool to unlock such files (or a reboot)

- some OS have permissions that may have locked you or your program out of the file. This usually happens when you changed from using a test file to a real one and the real one is not accessible.

Also make sure that .txt file is really .txt not .txt.txt.

Topic archived. No new replies allowed.
Pages: 12