Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-03-2011, 06:50 PM   PM User | #1
worldtraveller
Regular Coder

 
Join Date: Nov 2010
Location: canada
Posts: 131
Thanks: 51
Thanked 0 Times in 0 Posts
worldtraveller is an unknown quantity at this point
C++ to run on Apple MAc Computer

Hello I am starting some lessons on C++
I use an Apple Computer
IMac desktop

I am new using Xcode for C++ (and also for the language C++ itselfs), but i want to try to build a working commandline executeable with Xcode.

My code works with DevC++ on windows, but i'm using a mac at home and would like to test my apps.

will someone explain how i make a project for use with Xcode?

Basically I want to be able to run my C++ program right from Xcode without having to go to Terminal

Right now the program is working from Terminal.
But when i go back to Xcode it does not work. I get message of "build failed"

As well Would i be ok to just type my C++ code in Text wrangler and then run it all in Terminal?

I still would rather have it all work in one simple run from Xcode. please tell me how to do that. thanks

Problem is last simple program I got to work on my old Windows computer
when i run it i got the 2nd window to pop up.

When I run it on my MAC using Xcode. When i run and build
i get message of "build succeeded" which is good
but no second screen of the program working

here is the actual code

Ok Now I got Xcode to work.

I am not able to get the separate screen to work when i run a simple program.

So here is my program just a Helloworld program

Code:
#include <iostream.h>



int main()

{
int mynumber;
mynumber = 34
cout << " my number is ";
cout << "Hello world!" << endl;
cout << mynumber;
system("pause");
return 0;

}
So when i run it in Xcode, it works. it says build Succeeded
however i am supposed to get a second pop screen like a command prompt, like same when i run program on my Windows computer
that has "hello world" and 34 etc.

What function on Xcode do i use to make this happen?
thanks

Last edited by worldtraveller; 11-04-2011 at 12:32 AM.. Reason: need to add more information
worldtraveller is offline   Reply With Quote
Old 11-04-2011, 12:52 AM   PM User | #2
worldtraveller
Regular Coder

 
Join Date: Nov 2010
Location: canada
Posts: 131
Thanks: 51
Thanked 0 Times in 0 Posts
worldtraveller is an unknown quantity at this point
Ok here is what i have done next. I follow some instructions online and was able to get c++ to work and compile from xcode
but it only works in a different format.

this is what I have put in it that works in Xcode

Code:
#include <stdio.h>
 
int main (int argc, const char * argv[])
{
 
    // insert code here...
    printf("this is my first project\n");
     
    return 0;
}
And I get it to work. But how come it only works with the line as "printf"?
as the proper way to write that line is this
"
Code:
#include <stdio.h>
 
int main (int argc, const char * argv[])
{
 
    // insert code here...
    cout <<"this is my first project");
   
    return 0;
}
So when i try to run it this way , it does not work and i get error in my lines.
but this format works in Windows using the Dev C++ etc.

So what can you say? do i have to change the formats for Apple?
thanks
worldtraveller is offline   Reply With Quote
Reply

Bookmarks

Tags
c++, mac, xcode

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting 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

Forum Jump


All times are GMT +1. The time now is 05:26 AM.


Advertisement
Log in to turn off these ads.