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

jackfrost9p

macrumors newbie
Original poster
Sep 24, 2005
7
0
I am new to programming and am trying to use my powerbook at school, which of course is dominated by pc's. I have written very simple code in C using vi in terminal, but i dont know how to compile or run my code. Thanks for the help!!
 

jackfrost9p

macrumors newbie
Original poster
Sep 24, 2005
7
0
peterparker said:
If you have gcc installed:

gcc myfile.c -o myfile

well my file name is test.c
and if i tpye in gcc test.c -o test

i get this error

-bash: gcc: command not found

i dont know if this means i need to install gcc or not and if I do where can i get it thanks alot!
 

yg17

macrumors Pentium
Aug 1, 2004
15,027
3,002
St. Louis, MO
jackfrost9p said:
well i dont have my disk and i am not a developer, is there any other way to do it. Thanks alot you have been very helpful!

Its free to become a developer. On the link he posted, there's a link to sign up. Once you do that then you can download Xcode
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
jackfrost9p said:
well i dont have my disk and i am not a developer, is there any other way to do it. Thanks alot you have been very helpful!
Actually, you don't have to be a programmer by proffession to download x-code. I know I am not, I just gave some information and they let me download X-Code.

Here is what you will do:

Download X-Code and install it. Then make a new project. In the next dialog that appears you will see a selection of project types you wish to create. Choose "Carbon Bundle". That's it.

In the window that appears, just write the code, compile it and run it. You don't have to use the terminal or any other debugger, X-Code is just what you need.

I started just like that C++ programming.
 

seriypshick

macrumors member
Apr 4, 2005
76
0
Everywhere
jackfrost9p said:
Ok i did all that now how do i run the a.out file.

Thanks
Code:
./a.out
./ - means current dirrectory

but here's a better (right) way to compile:
Code:
gcc test.c -o test
then when it finishes compiling you type:
Code:
./test
instead of:
Code:
./a.out

a.out is a default program name if you don't specify what you wnat your program to be called

Good luck.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.