Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

maniac20

macrumors newbie
Original poster
Apr 26, 2008
8
0
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?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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?

"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.
 

maniac20

macrumors newbie
Original poster
Apr 26, 2008
8
0
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?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
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.
 

maniac20

macrumors newbie
Original poster
Apr 26, 2008
8
0
Thank you so much,I didn't know they had a different section.What is the c file for?
 

maniac20

macrumors newbie
Original poster
Apr 26, 2008
8
0
No,it when you create a new file there is the option to create a "C File" under C and C++ options.
 

psingh01

macrumors 68000
Apr 19, 2004
1,586
629
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.