New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Programming in C


Post Reply New Thread Subscribe

 
Thread Tools
Macman95

 
Member Since: Oct 14, 2009
Posts: 7
Macman95 is an unknown at this point
Mac Specs: MacBook, Orange-Clip iPod Shuffle

Macman95 is offline
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.
QUOTE Thanks
Macman95

 
Member Since: Oct 14, 2009
Posts: 7
Macman95 is an unknown at this point
Mac Specs: MacBook, Orange-Clip iPod Shuffle

Macman95 is offline
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.
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
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
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
@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
QUOTE Thanks
Macman95

 
Member Since: Oct 14, 2009
Posts: 7
Macman95 is an unknown at this point
Mac Specs: MacBook, Orange-Clip iPod Shuffle

Macman95 is offline
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.
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
Macman95

 
Member Since: Oct 14, 2009
Posts: 7
Macman95 is an unknown at this point
Mac Specs: MacBook, Orange-Clip iPod Shuffle

Macman95 is offline
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
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
@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
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
Macman95

 
Member Since: Oct 14, 2009
Posts: 7
Macman95 is an unknown at this point
Mac Specs: MacBook, Orange-Clip iPod Shuffle

Macman95 is offline
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?
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
Macman95

 
Member Since: Oct 14, 2009
Posts: 7
Macman95 is an unknown at this point
Mac Specs: MacBook, Orange-Clip iPod Shuffle

Macman95 is offline
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
QUOTE Thanks

Post Reply New Thread Subscribe


« cant restart mysql | how to copy unix executable file by java program that preserve their properties »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Mackbook or MBP for programming smilemoveon Apple Notebooks 5 02-13-2008 08:55 AM
Java Programming at School pr0wn3r Web Design and Hosting 5 11-25-2007 10:35 PM
Programming language rated knightjp OS X - Development and Darwin 8 09-30-2007 09:37 AM
Robotic NQC Programming ApplejustWorks Schweb's Lounge 0 01-31-2005 06:28 AM
Programming on the Mac natey OS X - Development and Darwin 4 06-29-2004 06:05 AM

All times are GMT -4. The time now is 08:29 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?