![]() |
|
#1
|
||||
|
||||
File opening problemSimple question how do you open a file in a folder eg files\help\help1.txt
because if you put that as the address to open a ofstream file CPP / C++ / C Code:
it thinks it is a file called fileshelphelp1.txt PS:What do you think of the avatar, i drew parts myself __________________
Forgive my english (I am english i just can't spell) PS:What do you think of the avatar, i drew parts myself |
|
#2
|
||||
|
||||
Re: File opening problemQuote:
I think you should use \\ instead of \ The Avatar looks very nice Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#3
|
||||
|
||||
Re: File opening problemQuote:
See this for a list of special chars. __________________
Age is unimportant -- except in cheese |
|
#4
|
||||
|
||||
Re: File opening problemIt doesn't work the program gets confused and can't write or read the file
__________________
Forgive my english (I am english i just can't spell) PS:What do you think of the avatar, i drew parts myself |
|
#5
|
|||
|
|||
Re: File opening problemQuote:
Post the entire code. Tell us what compiler and operating system you are using. If it is Windows, tell us what version (Windows98, Windows XP, or whatever). If you are running from inside a Graphical Interface (Visual C++ GUI, or dev-c++ or whatever) tell us that also. If you are running from a command line (window with a command prompt) tell us that also. Regards, Dave |
|
#6
|
||||
|
||||
Re: File opening problemi can't post the whole program because this is one part of a huge program (so far 6 header files 2 source files)
this is the code it is a help display function. CPP / C++ / C Code:
Output: Should be a function that displays a recuring menu which displays the contents of different files depending on the selection. Info: Compiler: Visual C++.Net Standard (2003 version). OS: Windows XP Home edition. App Type: Win32 Console app. Run Type: Standard Click on the icon. PS I know the buffers are wasteful but i haven't got around to changing it yet. __________________
Forgive my english (I am english i just can't spell) PS:What do you think of the avatar, i drew parts myself |
|
#7
|
|||
|
|||
Re: File opening problemQuote:
Quote:
But you should give enough code that we can compile and test. In fact, by reducing the code to a smaller amount that still displays the error, it might be quicker and easier for you to test and debug. (And faster than posting a request for help and waiting for a helpful response, I claim. It's always OK to ask, but...) A couple of program notes: First of all: When you open files, I think you should always test to see if it was successful. Secondly: When you get data input (from files or from user input on a console, or whatever...), I think you should always test to see if the conversion was successful. CPP / C++ / C Code:
And my output: Code:
Get this to run correctly first, then fix up your large program. Notes: You indicated that it is a Windows console application and you run the program by "standard click on the icon". I don't know exactly what this means to you, but here's what I did: I compiled the program, then with Windows Explorer, I navigated to the place where the ".exe" file was located. I double-clicked on the ".exe" thing and the program ran. Another way: I right-clicked on the .exe file in the Windows Exlplorer pane, dragged it to the Desktop, and when I released the mouse button, I selected "Create Shortcuts here". Now, I can double-click on the desktop icon to get it to run. Note that successful execution depends on the folder named "files" being under the folder where the .exe file is, and a folder "help" must be under that, and the file named helpMain.txt is there. (Normally, when I create command-line applications, I run them from a command line, not by clicking on the icon. That way, there's no question as to where the executable file is, and where the data files are, relative to it. I really prefer it that way, but that's just me.) In other words, when you use the "click on the icon" method to launch a program the default behavior is that the files are relative to the directory where the executable is located. If you right-click on the Desktop icon, you will see a window called "start in" and the path will be the path to your executable file. You can change this so that the files\help stuff can be anywhere you want. If you want to specify a particular path in your C file rather than a path relative to the location of the .exe file, then you can make the path absolute. For example if the help files are on the root of drive D: CPP / C++ / C Code:
If you want to create an output file, use the same rules for locating the file (absolute path or path relative to executable). Regards, Dave |
Recent GIDBlog
Meeting the local Iraqis by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| Download files in c for windows operating system | oozsakarya | C Programming Language | 5 | 20-Jun-2006 03:33 |
| difference between "rb" mode file opening and "rt" mode file opening | jaininaveen | C Programming Language | 3 | 15-Feb-2006 13:15 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 10:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The