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

amnost

macrumors regular
Original poster
Feb 6, 2010
142
0
United States
I am just beginning to learn C programming. I am going to buy the most popular textbook on it and learn. When I was reading about how C programming works, I was told that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute). Apparently, since macs are Unix-based, there is a c compiler included on my mac. Is this true? If so, how do I use it?
It said that the C compiler on Unix machines is called either "cc" or "gcc" and is available on the command line. What's that about? :confused:

Please help soon! Thanks!
 
XCode

Ok. So, I have the entire developer kit, that includes Xcode. But, which program should I open, and what do I do to make the C code I have executable? :confused:
 
Ok. So, I have the entire developer kit, that includes Xcode. But, which program should I open, and what do I do to make the C code I have executable? :confused:

How familiar are you with the Terminal app, and working around a Unix shell?

If not familiar, you'll either want to learn (it's not difficult, it just takes some getting used to) or use a GUI like XCode and define your project settings there. Even then, it's good to know how to work in a terminal window, especially since your first C programs are going to take text input and output from the console.
 
Explanation

:D I've decided to make this easier and just type up my whole story and exactly what I need to know and already know:

I have finished studying a little basic computer science architecture. I am now ready to start learning my first programing language. I have chosen C because it is one of the most important and most useful to know. I also heard that it is one of the best languages to learn as your first code language. I have found the worlds most popular book on how to program in C. Apparently it will work very well, and is fantastic for any skill level. Everything is good there. But there is one thing that confuses me greatly. Once I write up some code using the stuff I learn in this book, apparently in order for the computer to read it, it needs to be ran through a C compiler to make it executable. This is where everything gets fuzzy. I have the code, but I need to make it so the computer can read it and I can put it in a web page or Mac OS X app, or whatever it may be. I have learned that X Code can do these things. But, I am left unsure on how to do this. I have the entire Apple developer kit. I just don't know what to do upon opening the developer folder. I am unsure what is next. I have the C code, I just want to be able to make it so the computer can read it! I want to test my first basic C Code by just putting some test code onto my websites blog posts, and then removing it after I realize it works. So, basically I just want to take the C code I have, and make it so I can just use an HTML editor to put it on a website. But, this can't be done until the computer can read it, I am told.

In summary, What exactly am I doing wrong and how do I do the things above? :confused: :confused: :confused: :confused: :confused: :confused:
 
So, basically I just want to take the C code I have, and make it so I can just use an HTML editor to put it on a website.
You seem to have some fundamental misconceptions here that I'm not really sure how to address. Basically, you can certainly post your C source code to your blog, but you can't just plonk an actual application executable onto a webpage and have it run. Most interactive web page elements are done in Javascript, which is an interpreted language (but this is wandering off from the original topic of C).

For getting started on programming with Xcode, I'd recommend "Learn C on the Mac" (available in print or pdf here). It'll handhold you through getting your programs running, and there are followup books to introduce you to Objective-C (what OS X development mostly uses) and Cocoa/Cocoa Touch (the frameworks provided by OS X and iPhoneOS).
 
You seem to have some fundamental misconceptions here that I'm not really sure how to address. Basically, you can certainly post your C source code to your blog, but you can't just plonk an actual application executable onto a webpage and have it run. Most interactive web page elements are done in Javascript, which is an interpreted language (but this is wandering off from the original topic of C).

For getting started on programming with Xcode, I'd recommend "Learn C on the Mac" (available in print or pdf here). It'll handhold you through getting your programs running, and there are followup books to introduce you to Objective-C (what OS X development mostly uses) and Cocoa/Cocoa Touch (the frameworks provided by OS X and iPhoneOS).

Is HTML 5 a coding language of it's own?
 
Is HTML 5 a coding language of it's own?

No, strictly speaking HTML is a markup language. It's not even a "programming language" in the sense of being able to tell the computer to run a program to do certain things, it exists solely to define how web pages look. HTML tags can define what font a web page uses, for example, or which parts of the text are bold or italic. HTML tags define links to other pages, and links to images that the browser can embed in the page. If a web page does require some sort of programming to be included, the HTML code links to another bit of code written in, typically, Javascript.

At this point I strongly recommend learning how to work a Unix shell using the Terminal app, and doing some basic things with C from there. This will help you understand the mechanics of coding, compiling and running applications.
 
I think the important point you need to understand is that there's difference between a compiled language like C, and an interpreted language like Javascript or a markup language like HTML. With compiled languages, you write your programs in a human-readable language (e.g. C), then feed it to a compiler. The compiler reads the C, then outputs another file that's machine readable. The code you write cannot be run as a program, only the executable file that the compiler makes can be.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.