 Bubba_TFast Faisil Strikes AgainPremium join:2001-09-22 Columbus, IN | Compile and run C program in Xcode 3.1.2 Hey guys, just messing around in Xcode and trying to get my super simple C program to run, but I can't figure out how. Can you take a look at my screen and tell me what I need to do to get this program to run? I've Googled for the past 15 minutes and can't find anything. The program compiled with no errors, but how do I run it? -- He must have been an admiral a sultan or a king, and to his praises we shall always sing. Look what he has done for us he's filled us up with cheer! Lord bless Charlie Mops, the man who invented beer. |
|
 ThinkdiffPremium,MVM join:2001-08-07 Bronx, NY kudos:6 1 edit | Did you setup the project to create a command-line program or application?
If it's an application, you need to create an interface for it and link the output of your code to a window in your interface.
If you're just doing a command line program, after building it, go into the build folder inside your project folder, and you should find the executable. Open a terminal window, drag in the executable file and hit return. |
|
 Bubba_TFast Faisil Strikes AgainPremium join:2001-09-22 Columbus, IN | Ok, thanks for the tip. I don't think I was specifying that this was a command line utility. Also Johnny said to use Console and run from there so I could see my output. That works awesome too, but I'm not getting the result that I believe I should be getting. Can you take a look at my code and tell me if I've missed something? I've been staring at it for the past hour and can't figure it out.
* This is my first program using Xcode. It asks for two numbers, adds them together and gives the user the answer. */
#include <stdio.h>
int
main ()
{
int num1, num2, num3;
printf("\nThis program will add two numbers and give you the result.\n");
printf("Please enter the first number: ");
scanf("%d", &num1);
printf("\nPlease enter the second number: ");
scanf("%d", &num2);
num3 = num1 + num2;
printf("\nThe two numbers that you entered equal %d, num3");
return(0);
}
-- He must have been an admiral a sultan or a king, and to his praises we shall always sing. Look what he has done for us he's filled us up with cheer! Lord bless Charlie Mops, the man who invented beer. |
|
 | reply to Bubba_T
#include <stdio.h>
int
main ()
{
int num1, num2, num3;
printf("\nThis program will add two numbers and give you the result.\n");
printf("Please enter the first number: ");
scanf("%d", &num1);
printf("\nPlease enter the second number: ");
scanf("%d", &num2);
num3 = num1 + num2;
printf("\nThe two numbers that you entered equal %d\n", num3);
return(0);
}
|
|
 Bubba_TFast Faisil Strikes AgainPremium join:2001-09-22 Columbus, IN | Oh my gosh!!!!! Am I really that blind??? I had one '"' out of place and it was wreaking havoc on my program. Thanks Epyon9283  |
|
 Bubba_TFast Faisil Strikes AgainPremium join:2001-09-22 Columbus, IN | reply to Bubba_T Ok, now here's another question. I know this is a command line program, but could I make this, or other command line programs into a graphical type of progam/interface? I guess what I'm saying is, could I use interface builder somehow? -- He must have been an admiral a sultan or a king, and to his praises we shall always sing. Look what he has done for us he's filled us up with cheer! Lord bless Charlie Mops, the man who invented beer. |
|
 | Unfortunately, you're example wouldn't translate directly into use with IB. It'd be best to rewrite it in Objective-C from the start. I'd recommend heading over to cocoadevcentral.com and checking out their tutorials and if you really want to get into it, check out "Programming in Objective-C" by Kochan and "Cocoa Programming for Mac OS X" by Hillegass, both of which are excellent in my opinion. |
|