Problem opening a *.txt file in Xcode Command Line Application

Discussion in 'Mac Programming' started by Averello, Dec 23, 2009.

  1. Averello macrumors newbie

    Dec 23, 2009
    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:
  2. Detrius macrumors 68000

    Sep 10, 2008
    Asheville, NC
    Those look like compiler errors. You should not be trying to *compile* a txt file.
  3. sammich macrumors 601


    Sep 26, 2006
    If you're programming in C, you don't need to use XCode. You can use 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)

Share This Page