Hey guys, I need to get all the lyrics from my txt file into my program but unfortunately when I put a test run in there it keeps saying that the file is not found?? How to print out the txt file?
Btw, I get no errors. It just can't find the file for some reason.
And yes I have the txt file inside of the programs folder.
In order to open your input file the file must exist in the program's current working directory. Unfortunately the program's current working directory can vary depending on how you are running the program.
So please state your operating system, your IDE, if any.
True, but for some reason it still doesn't want to grab that txt file.... I'll play with it a bit and see if I can get it working.
If not I'll repost that issues are still occurring with no luck.
kurt@kurt-VirtualBox:~/Desktop/CPPDCOM/bin/Release$ ./CPPDCOM
My Text
That was from executing it from the terminal, and my text file was in the same folder as the executable. Executing it in Debug from inside Code::Blocks pulled the text file from the same folder that "main.cpp" was in.
I even tried moving the "folder" that has the txt file in it to the src file. Thinking maybe that would work but no luck! I have the txt file in a folder because there is going to be MANY txt files that need to be.. compressed/ put in one place to keep organized. Without putting it into a folder there would be MANY txt files all through the programs location folder.
It keeps saying, "error opening file". So... I'm taking it for some reason it isn't accessing the txt file. Ideas?
@das2
I have no use for making it writeable, only readable. I created the txt file by just entering the info in the notepad and saving it. Instead of creating it all by coding. It's a Time saver.
Well, in a Release build the CWD is supposed to the same folder that the executable is in. Are you running it in debug right now? Yeah, hard-coding a path would make it impossible to distribute.
Did you look at what the little code snippet says the current working directory is?
Yes I have the directory which is:
/home/codefreak/Desktop/C++ Projects/Lyrics
I moved the folder which is a old rock music band, Rainbow Band Info. out of the src folder but it is still in the program's folder (Lyrics).
I kind of figured that It might not work hard coding the dir path. So far I have 2 programs out there on the web that people can use (helpful) programs. So building software isn't new to me but this issue is the only thing stopping me from completing this piece of software.
Hey Jay, do you possibly have teamviewer? I will be on tomorrow well... later on tonight considering it is 12:45am my time.
I'm going to try getting teamviewer to work on my Ubuntu and if you have the time we can tackle this irritating issue together.
But I have no classes tomorrow, so I'll be perusing here, trying to tell people to ignore the trolls, while doing some studying. I'll be up for a while tonight, but only because I'm just not tired. Either that or I'm so tired that I've gone beyond 'tired' and into 'hyper'.
You can send a PM or bump your post some time tomorrow and I should see it. I check my email often, so I'll be alerted to a PM quickly.
Found what the issue was. I didn't save the file name under ".txt" and when I was trying to call the file WITH the .txt it couldn't find it.
Lol, simple mistake that took hours. Got it up and working now.