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

Weasler

macrumors newbie
Original poster
Jul 25, 2007
1
0
After programming on Windows for a while, I decided to come over to Mac and see port some of my work. But as it seems, for some reason XCode will not allow me to preform a simple task of making a Hello World application in Command Line C++. Here is a quick example (very very quick) of the language I know, and for some reason, it is not working, even though it works in Blodshed.

#include <iostream>
#include <stdlib.h>

int main(int argc, char *argv[])
{
cout << "Hello World" << end1;
return 0;
}



Any advice?
 
shouldn't that "1" be an "L"?

and i'd declare a namespace if I were you.

oh yea, you don't need the standard library either.

Code:
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
cout << "Hello World" << endl;
return 0;
}
 
in standards-compliant C++, iostream and therefore cout and endl are part of the std namespace.

so you want

std::cout

instead of the global
cout

also, i think you mean to be using std::endl and not std::end1

and generally speaking, avoid std::endl unless you need to explicitly flush the iostream immedately. you're often better off using the standard newline \n

http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.