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

xxcysxx

macrumors 6502
Original poster
Oct 12, 2011
264
1
hello folks,

in visual studio i can just use

using namespace std;
int main()
{
return 0;
}

and in xcode i have to use

using namespace std;
int main(int argc, const char * argv[])
{

return 0;
}

for it to work? how come i cant do the main without any argument in the parenthesis like i did in visual studio?
i tried to do it and get compile failed.

i did use google to search but i only understand what the argument does, but i still don't understand why xcode requires it where as visual studio doesn't.

thanks for any inputs folks
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,541
6,027
I generally write my C code in gEdit and then compile it by using make in Terminal... I'm pretty sure it'll compile without any arguments in main() just fine.
 

chrono1081

macrumors G3
Jan 26, 2008
8,443
4,139
Isla Nublar
? I never had to use them in Xcode. You *should* use them because its considered proper practice but most programming books omit them for some reason.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Most of the time when C++ code compiles on Windows and doesn't compile with either gcc or clang, it turns out that the code was illegal in the first place but some windows compiler still accepted it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.