Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > c programming

c programming
Thread Tools
ayyawar
Fresh-Faced Recruit
Join Date: Apr 2007
Status: Offline
Reply With Quote
Apr 4, 2007, 02:00 AM
 
hii every one. can anyone help me in C programming on mac

i got a new mac but i have lot of work with C programming..
i dont want to go with bootcamp or virtual PC just for C programming
is there any application which can run c programming..
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Apr 4, 2007, 02:13 AM
 
The Xcode Tools should be included with your system. Just install those and you're set.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
CharlesS
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Apr 4, 2007, 04:53 AM
 
If you don't have the XCode tools for some reason, you can download them for free from ADC Member Site (you'll have to sign up for a free Online ADC account).

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
ayyawar  (op)
Fresh-Faced Recruit
Join Date: Apr 2007
Status: Offline
Reply With Quote
Apr 4, 2007, 05:17 AM
 
Thanks for ur replay for my question on "C" programming i have installed the xcode but. i dont know what to do next i mean where should i write the programm and can i compile that programm. for my results..
thank you again
kapil ayyawar
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Apr 4, 2007, 05:21 AM
 
File->New Project->Command Line Utility->Standard Tool

Give the project a name and then click the "Build & Run" button and you have made and run your first C-program. Edit the file main.c that you can find in the "Groups & Files" list at will to create your own program.
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Apr 4, 2007, 05:51 AM
 
or to do it the traditional way, on the CLI, use vi to edit the code, and gcc (or g++) to compile it.

But using the XCode is much easier. It uses gcc internally, anyhow. It is located at: /Develope/Applications (after you've installed the developer tools)
     
Wee
Fresh-Faced Recruit
Join Date: Mar 2007
Status: Offline
Reply With Quote
Apr 4, 2007, 02:58 PM
 
what about C++ ?
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Apr 4, 2007, 03:14 PM
 
Originally Posted by Wee View Post
what about C++ ?
Same. GCC supports several languages, including C++.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
mitchell_pgh
Posting Junkie
Join Date: Feb 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Apr 6, 2007, 09:38 AM
 
Originally Posted by Brass View Post
or to do it the traditional way, on the CLI, use vi to edit the code, and gcc (or g++) to compile it.

But using the XCode is much easier. It uses gcc internally, anyhow. It is located at: /Develope/Applications (after you've installed the developer tools)
I wouldn't recommend this for someone starting out. I would use Xcode for now and when you figure out the limitations of it, move on.
     
ayyawar  (op)
Fresh-Faced Recruit
Join Date: Apr 2007
Status: Offline
Reply With Quote
Feb 14, 2008, 02:27 AM
 
Hii everyone..

I have been using Xcode to write C programs. It works great..
but i have been using some of the gnu functions.. which need gnu scientific library
installed in it. I don't know how to install gnu scientific library into Xcode.
Is anyone can help me to install gnu library into Xcode.
thanks in advance.

Kapil Ayyawar.
     
DarkStarRed
Dedicated MacNNer
Join Date: Jun 2005
Status: Offline
Reply With Quote
Feb 14, 2008, 04:22 AM
 
I think this might help you Nicolas Clauvelin - XCode and GSL HowTo
last updated in Jan 2008.
     
Warhaven
Dedicated MacNNer
Join Date: Jul 2002
Status: Offline
Reply With Quote
Feb 16, 2008, 12:13 AM
 
As a good general purpose editor (no fancy IDE development stuff or anything), you may also want to look into BBEdit. It's like NotePad++ on Windows.
     
ntsc
Senior User
Join Date: Sep 2000
Location: Glasgow, Scotland UK
Status: Offline
Reply With Quote
Feb 19, 2008, 08:37 AM
 
Or if you interested in plain text editors I like SubEthaEdit a little less pricey that BBEdit and comes with a handy collaboration feature if you have friends you code with who are Mac users.
( Last edited by ntsc; Feb 19, 2008 at 08:37 AM. Reason: screwed up the markup)
"You can't waste a life hating people, because all they do is live their life, laughing, doing more evil."

-ALPHA ROBERTSON,whose daughter was one of four girls killed in the bombing of a Birmingham, Ala., church in 1963.
     
naphtali
Dedicated MacNNer
Join Date: Mar 2003
Status: Offline
Reply With Quote
Feb 22, 2008, 10:33 AM
 
Wow sounds really nooby but I didn't know Xcode could do that!

Got quite frustrated trying to learn C from a book cos I couldn't even the book's compile and run instructions to work on Terminal:

It says to compile with "cc name.c" and then to run "a.out".
The simple program compiles with no problems and generates the a.out file, but typing "a.out" as the book suggests returns command not found

Does anybody know what's going on?

Works great on Xcode
     
anilnair
Fresh-Faced Recruit
Join Date: Feb 2008
Status: Offline
Reply With Quote
Feb 22, 2008, 10:39 AM
 
Try ./a.out

Your path may not include the current directory, and it is not finding the a.out
     
naphtali
Dedicated MacNNer
Join Date: Mar 2003
Status: Offline
Reply With Quote
Feb 22, 2008, 12:18 PM
 
Originally Posted by anilnair View Post
Try ./a.out

Your path may not include the current directory, and it is not finding the a.out
Hi Anil thanks for the reply - it works! What's going on behind the scenes that makes it work now? Why is it that it doesn't work when I navigate to the proper directory before compiling and running the file?
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 22, 2008, 12:34 PM
 
Originally Posted by naphtali View Post
Hi Anil thanks for the reply - it works! What's going on behind the scenes that makes it work now? Why is it that it doesn't work when I navigate to the proper directory before compiling and running the file?
When you type a naked command (like "a.out"), it searches a predefined set of directories — contained in the environment variable PATH — for a matching executable. If the current directory isn't in that list, it won't bother looking there. The first dot in "./a.out" refers to the current directory, so that command means "run the program a.out that's in the current directory."
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
naphtali
Dedicated MacNNer
Join Date: Mar 2003
Status: Offline
Reply With Quote
Feb 22, 2008, 10:24 PM
 
Originally Posted by Chuckit View Post
When you type a naked command (like "a.out"), it searches a predefined set of directories — contained in the environment variable PATH — for a matching executable. If the current directory isn't in that list, it won't bother looking there. The first dot in "./a.out" refers to the current directory, so that command means "run the program a.out that's in the current directory."
Thanks! It doesn't seem to intuitive to me though, that it might look elsewhere but the current folder Perhaps for frequent shortcuts and stuff. Will go brush up on Unix paths etc

Have a great weekend!
     
CharlesS
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Feb 23, 2008, 04:27 AM
 
It's for security, I think - if typing a command searched the current directory, someone could stick a malicious program named "ls" into your home directory, and then if you opened up a Terminal window and typed "ls", whoops, you just ran the malicious program instead of ls. It would get particularly nasty if you put sudo in front of the command.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
naphtali
Dedicated MacNNer
Join Date: Mar 2003
Status: Offline
Reply With Quote
Feb 24, 2008, 11:12 AM
 
Originally Posted by CharlesS View Post
It's for security, I think - if typing a command searched the current directory, someone could stick a malicious program named "ls" into your home directory, and then if you opened up a Terminal window and typed "ls", whoops, you just ran the malicious program instead of ls. It would get particularly nasty if you put sudo in front of the command.
Thanks! Makes sense! My *nix-fan brother-in-law and I were discussing it and we came to the same conclusion too
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 10:36 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,