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

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

  1. macrumors newbie

    Joined:
    Dec 23, 2009
    #1
    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. macrumors 68000

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

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #3
    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:

    Code:
    gcc -o your_program_name /path/to/your/program
    For example, you have the file called my_prog.c on your desktop:
    Code:
    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