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

Doug.Mellon

macrumors newbie
Original poster
Mar 26, 2006
7
0
I am new to mac C++ programming and have a quick question... I created a simple program that I want to execute in terminal. I was wondering what file I click on to do this? I have the C++ xCode project saved on my desktop so I went in that and cant find the executable. I have tried a bunch of diffrent stuff but it keeps opening in xCode.
Any help would be awsome!
Thanks in advance,
Doug

EDIT: I was also wondering how you can get somthing to beep continusly?
 

Doug.Mellon

macrumors newbie
Original poster
Mar 26, 2006
7
0
hahaha... no no, that doesnt have to do with my app haha. Just wanted to know for fun.
 

mrichmon

macrumors 6502a
Jun 17, 2003
873
3
Doug.Mellon said:
I created a simple program that I want to execute in terminal. I was wondering what file I click on to do this?

Open the terminal, then run the executable that is in the build/Debug directory of your XCode project.

EDIT: I was also wondering how you can get somthing to beep continusly?

If this program is to be run from the terminal then a control-G character (ascii code decimal 7) will make the terminal beep. Put that into a loop:

Code:
while(0) {
    printf("%c\n", 7);
}
 

Doug.Mellon

macrumors newbie
Original poster
Mar 26, 2006
7
0
ok... this may sound really dumb but hang with me. I opened terminal and went file -> open -> and it wouldnt let me open the executable... then relized i prob. had to type somthing in, in the terminal itself. If this is the case what would I type...
thanks for being patient.
~ Doug
 

mrichmon

macrumors 6502a
Jun 17, 2003
873
3
Doug.Mellon said:
ok... this may sound really dumb but hang with me. I opened terminal and went file -> open -> and it wouldnt let me open the executable... then relized i prob. had to type somthing in, in the terminal itself. If this is the case what would I type...
thanks for being patient.
~ Doug

I would suggest that if you don't know how to use the terminal shell then you should either first learn how to use the shell, or try to write a different type of program.

You will need to change directory to the folder in which the executable resides and then type in the name of the executable.
 

steelphantom

macrumors 6502a
Oct 15, 2005
555
1
If you're just writing simple one-file programs, which I assume you are doing now, just code your program in a text editor (such as Smultron) and then use CPP Edit to compile it. I've been using this combination for a while now, since I'm only writing simple programs at the moment. Once I get into programs with additional headers and stuff I'll move over to Xcode.
 

Doug.Mellon

macrumors newbie
Original poster
Mar 26, 2006
7
0
Cool thanks alot for the help guys...

steelphantom said:
If you're just writing simple one-file programs, which I assume you are doing now, just code your program in a text editor (such as Smultron) and then use CPP Edit to compile it. I've been using this combination for a while now, since I'm only writing simple programs at the moment. Once I get into programs with additional headers and stuff I'll move over to Xcode.
ill try that out.
 

mwpeters8182

macrumors 6502
Apr 16, 2003
411
0
Boston, MA
The best way to learn how to code is to become familiar with the terminal, and use a simple text editor to get started.

save the file as [filename].cpp, then just use g++ -o [filename] [filename.cpp]

./filename will then run the exec.

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