I'm trying to figure out how to get text from a file, but the user inputs the file name so they can change which file they can use. I wrote a short little code that should at least output the first word of the file, but nothing. I'm new to using files in programming so any help would be great!
I'm using a .txt file with made up stock information on it:
FedEx Corp (FDX)
112.57 .53 100
113.77 1.5 75
Are the files in the same directory as where you're running the program from? Do the files have an extension you can't see because windows is hiding the truth from you?
@toast9: No, the location of the cpp file has nothing to do with your program's working directory. Can you tell me how you run your program? Do you use an IDE? Or the commandline?
So I looked around for the directory and found it. I'm using Xcode to write the program and its default directory is really really buried. I changed the directory to a folder I made in the project fold, but it still doesn't work. Any ideas?
is there a way to choose a new path where the .txt file comes from?
I don't know where the command line is, but I did finally found where the directory is (Xcode/DerivedData/NAME_OF_PROJECT/Build/Products/Debug/) and put my file in there and it works! Thanks for the help. :)