PDA

View Full Version : Problem opening a *.txt file in Xcode Command Line Application




Averello
Dec 23, 2009, 07:25 AM
Good Morning,
I am trying to manipulate a *.txt file in a Command Line Application in Xcode.
There is a text file that has for example two lines, with words/phrases and some numbers.
All I want to do is to search for the numbers, save them in some variables, sum them and after, write them in a new file.
My problem is that when I make fopen I get an error

error: expected '=', ',', ';', 'asm' or '__attribute__' before each word of my file

I don't know what to do, and the problem is that I don't know very well programming in C.
I am trying to learn.
Any help for understanding the problem and solving it would be appreciated!

I am waiting in hope for your enlightement! :D

George :apple:



Detrius
Dec 23, 2009, 08:39 AM
Those look like compiler errors. You should not be trying to *compile* a txt file.

sammich
Dec 23, 2009, 08:46 AM
If you're programming in C, you don't need to use XCode. You can use TextWrangler (http://www.barebones.com/products/TextWrangler/) (free), and write code in that, save it, and compile it from in Terminal with the command:

gcc -o your_program_name /path/to/your/program
For example, you have the file called my_prog.c on your desktop:
gcc -o my_cool_program ~/Desktop/my_prog.c

Rewrite your program in TextWrangler and try the above and see what errors you get.

(~ is your home directory in case you didn't know)