I have this pointless program that accepts an integer as a command line argument and uses a text file that lists a bunch of prime numbers to find the prime factorization of that number. I just made it to test out some concepts and it works when I run it from Xcode with the parameters set in the project, but when I run it from the terminal and enter the argument, I get a Floating Point exception. What would cause a program to run fine in the project but have that error in Terminal?
Edit: it may be that the file doesn't open primes.txt in terminal. Does anyone know how to get a separate file to open in a program while running from terminal?
Yeah, I realized that the problem was that the file doesn't open. Does anyone know how to open a file when you run a program from Terminal? What directory do you have to put it in? Or do you have to enter the directory as a command line argument somehow?
The way the program is written now, it reads the file from the current working directory. You can change the program to specify the full pathname to the file or you can launch the program from the directory that the file is in.