Jump to content

Visula C++ 6.0 to Xcode help!


nate256
 Share

9 posts in this topic

Recommended Posts

So i am starting Intro to C++ this year and we had a couple weeks of class and so far i can do little programs

but I wanna use Xcode at home, but at school we use Microsoft Visual C++ 6.0.

 

so here is an example of a code we would use in Visual

 

#include <iostream.h>
main ()
{
cout <<"nathan is cool";
 return 0;
}

 

So is the <iostream.h> what is causing me trouble?

i there another header i should use?

how can i get like that to work in Xcode?

Link to comment
Share on other sites

#include <iostream>
main ()
{
cout <<"Nathan";
retutn 0;
}

 

 

now it doesnt see cout like what is the header i should be using???

Link to comment
Share on other sites

ok so i figured it out a lot more here is my code for figuring out the tax on an amount of money, I know exiting :rolleyes:

#include <iostream>

int main () {
// insert code here...
const float SALES_TAX = .06;
float costOfItem, amountOfTax;

std::cout <<"What is the cost of the item?\n";
std::cin >> costOfItem;

amountOfTax = SALES_TAX * costOfItem;

std::cout <<"You must pay ";
std::cout << amountOfTax;
std::cout << " dollars in taxes\n\n\n\n";

return 0;
}

 

so all i need to remeber is std:: before cout and cin

is there any way to put something in the header so that i do not need to do the std::?

Link to comment
Share on other sites

If I remember correctly, putting

using namespace std;

right after the includes should eliminate that problem.

 

Namespaces are kind of a newfangled addition to C++... google it to find out more, I can't explain them all that well.

Link to comment
Share on other sites

yea i figured that out.

 

so it is just like in Visual now :rolleyes:

 

but like when i get a program, is there a way to save it as like an executable file?

so i could like send it to someone?

Link to comment
Share on other sites

well yea but how do i make a bootable copy of the program i made in Xcode so another mac user could run it?

Link to comment
Share on other sites

 Share

×
×
  • Create New...