Beginner help.

Discussion in 'Mac Programming' started by maniac20, Apr 26, 2008.

  1. maniac20 macrumors newbie

    Joined:
    Apr 26, 2008
    #1
    Well at my high school I am learning C programming.At my school they basically have all windows that run Bloodshed C++,the problem is that I am new to xcode.In bloodshed I am easily able to run my code in bloodshed but when i type the same code for xcode i am unable to debug and compile it. Basically,all I am asking is how can i get it to compile?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    "Build and Go" should be the same as "Compile and run". "Build and Debug" should get you into GDB, but I don't know what debugger you are using in the other environment.

    What kind of errors are you getting? Compile errors? Link errors? Runtime errors?

    -Lee

    P.S. Are you learning C or C++? It shouldn't be too important, but just so we know what you're working on.
     
  3. maniac20 thread starter macrumors newbie

    Joined:
    Apr 26, 2008
    #3
    That the thing in Bloodshed I am able to quickly type up code and run it.In xcode I would type code in but it would not allow me to run it.It remains gray.

    Im learning C as of right now in my accelarated C programming class ,but will start learn how to do c++.I do know a little bit of c++,also is there a tutorial that shows how to make a gui c++ or c application?
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    When you choose a new project, there is a "Command Line Utility" category. Choose "C++ Tool" for C++ or "Standard Tool" for C. From there the project should be setup with the defaults you need, and a skeleton main function you can expand.

    From there, there "Build and Go" should compile and run the program. The skeleton provided is ready to compile and run immediately, and you can continue to Build or Build and Go as you are ready to test things.

    -Lee
     
  5. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #5
    You need to make a project, not a new empty file.

    Select File -> New Project.

    In the window select "C++ Tool" or "Standard Tool" depending on what language you are actually using - you said C, but that may have been shorthand for C++ for all I know.

    Once you have a project you can type in the code to run in the main() function in the main.c source file and then run it and stuff. In Xcode in the Run menu is the Console for input/output while running from within Xcode.

    To debug set a breakpoint (click in the numbers column in the far left of the source code editor window) and run the program, it should stop at the breakpoint. Open the Debugger window from the Run menu and you can step over the breakpoint or continue or whatever.

    Since there are so many distinct versions of Xcode you may need to dig around and find the correct project type - look for "tool" or "command line" projects.
     
  6. maniac20 thread starter macrumors newbie

    Joined:
    Apr 26, 2008
    #6
    Thank you so much,I didn't know they had a different section.What is the c file for?
     
  7. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #7
    You mean main.c? that is your source file. you can add others if needed.

    -Lee
     
  8. maniac20 thread starter macrumors newbie

    Joined:
    Apr 26, 2008
    #8
    No,it when you create a new file there is the option to create a "C File" under C and C++ options.
     
  9. psingh01 macrumors 65816

    Joined:
    Apr 19, 2004
    #9
    A file that ends in .c :)

    That means you can only use C code there. If you use the C++ file then it has a different extension.
     

Share This Page