Jump to content
6 posts in this topic

Recommended Posts

I have to program basic programs in C++ for my class. I use to use Quincy which would run programs in the ms dos.

 

I need something that would run the same code and run it in the terminal.

 

How do I do this in xCode or is there a simpler program???

 

I'll be running Windows in Parallels probably just to be consistent.

Link to comment
https://www.insanelymac.com/forum/topic/44658-need-guide-on-c-in-xcode/
Share on other sites

Thank you.. one more thing..

 

this is the code it shows at start..

 

#include <iostream>

 

int main (int argc, char * const argv[]) {

// insert code here...

std::cout << "Hello, World!\n";

return 0;

}

 

I am use to doing it this way..

 

 

#include <iostream>

 

int main () {

// insert code here...

cout << "Hello, World!\n";

return 0;

}

 

How do I make it so I can program the 2nd way?

 

Thanks!

That's been my problem too. I've been needing to re-learn C++, and I want a Mac-based compiler that will let me program the "old" way.

 

EDIT: I've discovered that this is the same with a lot of UNIX-based compilers. It seems that many Windows compilers assume the standard library, while it must be declared in UNIX.

 

Sticking a namespace declaration under the #include tags can eliminate the problems you and I described.

 

#include <iostream>
using namespace std;

int main()
{
 cout << "Hello, World!\n";
 return 0;
}

 

Simply declaring the namespace will cause the above code to compile without issues.

Edited by ErBiC
×
×
  • Create New...