Programming in C

Joined
Oct 14, 2009
Messages
7
Reaction score
0
Points
1
Your Mac's Specs
MacBook, Orange-Clip iPod Shuffle
I bought the book C for Dummies (its the desk reference that is like 800 pages thick and has like 7 books in 1) I am beginning to learn C. However, when I mean beginning, i mean THE VERY BEGINNING. All I know so far is a couple lines of code that I put in TextEdit and saved it as a .C file The author talks about compiling it and some command but I have no idea how to turn the code into an application!! CAN SOMEONE PLEASE HELP!

also when i saved the textedit file as a .C file, it now opens in XCode.

so yea once again I dont know how to Compile my C Code into an app please help!

THANKS IN ADVANCE.
 
OP
M
Joined
Oct 14, 2009
Messages
7
Reaction score
0
Points
1
Your Mac's Specs
MacBook, Orange-Clip iPod Shuffle
Developing an iPhone/iPod Touch App.

Hi i have a huge desire to create my own game on and iPod Touch and get it in the app store. I already downloaded iPhone SDK. Can someone please explain to me exactly what Objective C is (i think is a language but i am not sure) and exactly what Cocoa is.(i have not idea what cocoa is...) Someone told me i needed to learn both of those to make an app but I need to know what they are, and some book/website recommendations of how to learn them. I AM A COMPLETE BEGINNER WITH NO CODING/DEVELOPING/PROGRAMMING EXPERIENCE AT ALL! I DO HOWEVER KNOW HOW TO USE A MAC BECAUSE I HAVE BEEN FOR 3 YEARS.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Objective-C is indeed a language, it adds OOP (Object Oriented Programming) mechanics to C and is the chosen language for programming on the Mac.

Cocoa is the framework provided by Apple to program applications on the Mac, a version of this framework has been created for the iPod Touch/iPhone called Cocoa Touch.

To develop native applications on the iPod/iPhone that are not gaming related you need to learn Obj-C and the Cocoa Touch framework and use the various interfaces provided to you.

The moment you say you want to do a game, you need to being OpenGL and OpenAL into the picture and these are the graphics and audio frameworks respectively.

There are some alternates to dealing with OpenGL (or at least limiting how much you use it) by using things like cocos2d which is a gaming framework that allows you to get going quickly.

YOu will want to take a look at these 2 books, they deal with learning Objective-C and the iPhone SDK.

Amazon.com: Programming in Objective-C 2.0 (2nd Edition) (9780321566157): Stephen G. Kochan: Books
Amazon.com: Beginning iPhone Development: Exploring the iPhone SDK (9781430216261): Dave Mark, Jeff LaMarche: Books

Now if you have no coding experience at all, do it the right way by first learning the language and then the SDK and go from there. Expect to spend minimally 3-6 months to get fully comfortable with Obj-C and another 2-4 months with the SDK..

Regards
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
Raz0rEdge,

I think it would have been better to say that Objective-C is a superset of C, since anything you can do in C, you can do in Objective-C. Your response in the other thread is a better one.

I mentioned this here for future readers who might get the idea that Objective-C excludes the capabilities of C, which I think your answer may give some readers.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
@xstep, you are correct sir..C < (Obj-C | C++)...the geek in me..:)

@Macman95; In XCode, File->New Project. Choose Application and then Command Line Tool. In the Type choose C, then hit Choose and create a name..

This will create a simple C project that you can immediately build and run. You can then modify it further..

Regards
 
OP
M
Joined
Oct 14, 2009
Messages
7
Reaction score
0
Points
1
Your Mac's Specs
MacBook, Orange-Clip iPod Shuffle
ok Raz0rEdge, i went to XCode, i did File->New Project. I chose MacOSX (not iPhone OS) then I chose Application. After application, there were a bunch of different types of applications like Cocoa, Carbon, and all these others but i didnt see Command Line Tool. Can u help? am i in the right spot?

wait i think i found it. my XCode must be different from yours because mine was under Command Line Utilites, not Applications. okay now i have it but i dont know where to type in my code.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
I, now, agree with the OP, the threads are not duplicates. One is about working with C, while the other one is a general question regarding iPhone development. The OP says he edited one of his original posts and I recall thinking that they were close enough to being to duplicates. Anyway...

I looked up that book Macman95 mentions, via Amazon, and found a review that says it is Windows slanted. This could cause issues with using it on other systems such as OS X, Linux, Sun OS, etc. It is best to buy books targeted at your platform. The books Raz0rEdge mentions are such books. Check Amazon for Cocoa programming books.

I agree with Raz0rEdge that for a newbie it will take some time to learn both Objective-C and then the frameworks. There is no shortcut, but some people do learn faster than others. Designing applications is the other half of the equation that is a difficult process too. Perhaps keep this link in mind; Book Review: Cocoa Design Patterns.

I disagree that OpenGL is required for a game. That is too broad a statement. To keep it simple, Tic-Tac-Toe would not require OpenGL, although it might be neat to use for some cool factor. Ditto for OpenAL.

Macman95, you may want to look at resources such as BecomeAnXcoder and CocoaDevCentral. As you go forward, you'll want to get a free membership to the Apple developer programs.
 
OP
M
Joined
Oct 14, 2009
Messages
7
Reaction score
0
Points
1
Your Mac's Specs
MacBook, Orange-Clip iPod Shuffle
ok can someone please please please tell me exactly what programs i need to write the code for C and then compile it into an app???? this is extremely frusterating!!!!!
i know how to write a couple lines of a basic app in C but everyone is telling me mixed info!!! am i supposed to use TextEdit? XCode? Where do i get a Compiler? what is Terminal??? OMGOM!?!?!!??? PLEASE HELP
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
@Macman95, sorry I should have mentioned that I'm using SL with the latest XCode, so things might be moved around a little bit..

I'm at work, so bare with me as I guess a little bit..but in the left frame you should see various files that you can modify with a .c extension? Clicking on it should reveal the basic C code that's there, you can modify that for a start.

I will have to get home and take a look at this to provide a more detailed answer..

Regards
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
For the 'Command Line Utility', choose 'Standard Tool'. Look in the 'Source' tab and you'll see main.c where double clicking that opens the file in an editor.

To add a new source file, from the menu choose File-->'New File...'. Under 'Mac OS X', choose 'C and C++', and then 'C File' or 'Header File' if appropriate. The file(s) will be created into your Resources folder of your project.

To learn more about XCode, from the menu choose Help-->Documentation.
 
OP
M
Joined
Oct 14, 2009
Messages
7
Reaction score
0
Points
1
Your Mac's Specs
MacBook, Orange-Clip iPod Shuffle
ok xstep i found the main.c but it already has code in it, where do i write my own code?

also, what is a source file?
lastly, how do i compile my code after i write it?
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
XCode has it's own editor with benefits over TextEdit. I would recommend using the XCode editor.

You say you have installed XCode, so you have the C compiler already installed.

Look under XCode's 'Build' menu for building and running code. As an alternative, you can use Terminal by setting your folder location and executing C build commands. This 'C Tutorial for Cocoa' discusses shows some of the compiler commands. You'll have to look for some Terminal reference since I don't know of any. To change directories you use the cd command. Open Terminal, in the Utilities folder, and type 'man cd' without the quotes. man is the command used to get help on other commands.

Type the following into Google to find some help on learning to use Terminal

"OS X" learning to use terminal​

You are getting frustrated because you are piling on a lot of things in a jumbled manner. It would be best to take a course or find a book for that can guide you.

I just found Masters of the Void. It is something you should look at. I found it by typing the following into Google;

learning to use XCode for C​
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
A source file is a file with code in it. XCode created one for you called main.c. You can remove all the code in it and replace it with your content. It is called source because that is the source material the compiler will use to build your running application.

Read some of the links I've given you for your other answers.
 
OP
M
Joined
Oct 14, 2009
Messages
7
Reaction score
0
Points
1
Your Mac's Specs
MacBook, Orange-Clip iPod Shuffle
ok so I was using my C for dummies book and trying the code in xcode and i was getting all sorts of error message and i was getting frusterated.
finally, i decided to use the Masters of the Void link, and 5 minutes into it... everything started working! thanks for help
im going to use my book only to teach me the language, but do format it and use things in xcode im gonna use the Void tutorial. thanks

i will post any further troubles or questions i have in this forum
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top