![]() |
|
#1
|
|||
|
|||
Error in opening the fileHi all,
I am a beginner in C++ and I have the following problem: I try to open the file Test.txt, but it will not open the file. The Text.txt file is in the same directory where my C++ files resides. How can I check why the program fails to open the file. CPP / C++ / C Code:
Thanks in advance, Johan |
|||
|
#2
|
||||
|
||||
Re: Error in opening the fileHow are you running it? IDE or EXE? What compiler? What O/S? Please provide details.
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#3
|
|||
|
|||
Re: Error in opening the fileReally , try to provide more next time.
The function looks OK as far as file reading goes. Did you check file permissions on Test.txt? |
|
#4
|
|||
|
|||
Re: Error in opening the fileI use CodeGear RAD Studio as my compiler, so IDE.
OS: Windows XP SP3. File permissions: How do I check them in Windows XP? I have the same function working in C, but I would like to change it to C++. For standard C, see the working code below. CPP / C++ / C Code:
|
|
#5
|
|||
|
|||
Re: Error in opening the filedude, that's not standard C. And is is more involved that the first one you posted.
You should be simplifing your code until you can read the file properly , then start building it up. Yes in XP I don't think file permissions are an issue. In linux it definitely can be. If you are running in an IDE , the txt file may not be in the same directory that you are executing the program from. Who knows , but In that case you might try the full path for the filename: c:\this\that\theother\Test.txt Here is an adaptation of you first code to try. It works for me in linux and Xp. I use the gnu gcc compiler on the command line for each: CPP / C++ / C Code:
Code:
|
|
#6
|
|||
|
|||
Re: Error in opening the fileThanks Howard_L,
It works now. The Text.txt file was in the same directory as where I execute the program from, but there was something wrong with the path. Now, I navigate to the directory where the file is located, and now it works fine. CPP / C++ / C Code:
Thanks for your help. Johan |
Recent GIDBlog
Programming ebook direct download available 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 08:44 |
| After execution - Error cannot locate /Skin File? | WSCH | C++ Forum | 1 | 05-Mar-2005 21:03 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| CD Buring Failed | skanth2000 | Computer Hardware Forum | 1 | 15-Nov-2003 04:52 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The