| Replies
|
|
|
Misero
|
Posted at 7:06 pm on April 9, 2006 |
| Firstly, have you got "#include <iostream>" in your code? You need to do that for the object 'cin' to be defined. If you've already done that, then learn about 'namespaces', because it is my guess that this is your problem. I might be wrong, but it's hard to tell without seeing your code. Basically, the object 'cin' is defined within a namespace called 'std'. That means the object's full name is 'std::cin'. You can refer to it like that in your code. This is my preferred method. If you really want to just refer to it as 'cin', you'll have to import the name 'cin' into your working namespace. You can do that in more than one way. One way is to use: using namespace std; This will import all names from the std namespace so that they are accessibly without the 'std::' prefix. Another way is to use: using std::cin; This only imports the one name, 'std::cin'. It's better because you won't pollute your namespace with all sorts of names from the 'std' namespace that you won't use. If you're going to do it that way, put one of those lines directly after the '#include <iostream>' line. But like I say, I prefer to just use fully qualified names so as to avoid importing any names at all. (Edited by Misero at 3:09 am on April 10, 2006) |
|
|
steel
|
Posted at 11:05 am on July 20, 2005 |
Quote: from Duekiller at 11:00 pm on July 17, 2005
Quote: from helloworld at 3:20 pm on July 17, 2005
Quote: from Duekiller at 1:35 pm on July 5, 2005
Sorry to tell you this so late, but your problem is that the libaray that defines cin, is not on the mac because macs have diffrent libraries and shit so you need to grab the mac library (remember C++ is translated into ASSEMBER and then into machine code)
What the hell are you talking about? Mac OS X is Unix. Any decent Unix system ships with all the standard ISO C++ libraries. Mac OS X has done so from day 1. The Xcode developer tools ship with all the associated headers and the GNU compiler tools. If you have the tools installed, you can compile anything that is standard ISO C++. | Code: | #include <iostream> using namespace std; int main( void ) { int x; cout << "Test"; cin >> x; cout << x; return 0; } | Works fine for me. Stick it in a cpp file, run g ++ on it and, boom, done. (Edited by helloworld at 3:22 pm on July 17, 2005) 
Macs use the powerPC architecture and that has diffrent machine instruction codes, meaning that macs will have diffrent binary codes. That is why you cant install windows on a Mac. If you have the windows library then you need the mac specific library. 
Deukiller, im not sure you know what you are talking about. C++ is a high level programming language. You can use the standard libraries anywhere regardless of the Operating System. It is up to the compiler to convert it into machine-readable code. Asm on the other hand is a low-level programming language, instructions differ from one architecture to another. |
|
|
Duekiller
|
Posted at 8:00 pm on July 17, 2005 |
Quote: from helloworld at 3:20 pm on July 17, 2005
Quote: from Duekiller at 1:35 pm on July 5, 2005
Sorry to tell you this so late, but your problem is that the libaray that defines cin, is not on the mac because macs have diffrent libraries and shit so you need to grab the mac library (remember C++ is translated into ASSEMBER and then into machine code)
What the hell are you talking about? Mac OS X is Unix. Any decent Unix system ships with all the standard ISO C++ libraries. Mac OS X has done so from day 1. The Xcode developer tools ship with all the associated headers and the GNU compiler tools. If you have the tools installed, you can compile anything that is standard ISO C++. | Code: | #include <iostream> using namespace std; int main( void ) { int x; cout << "Test"; cin >> x; cout << x; return 0; } | Works fine for me. Stick it in a cpp file, run g ++ on it and, boom, done. (Edited by helloworld at 3:22 pm on July 17, 2005) 
Macs use the powerPC architecture and that has diffrent machine instruction codes, meaning that macs will have diffrent binary codes. That is why you cant install windows on a Mac. If you have the windows library then you need the mac specific library. |
|
|
helloworld
|
Posted at 12:20 pm on July 17, 2005 |
Quote: from Duekiller at 1:35 pm on July 5, 2005
Sorry to tell you this so late, but your problem is that the libaray that defines cin, is not on the mac because macs have diffrent libraries and shit so you need to grab the mac library (remember C++ is translated into ASSEMBER and then into machine code)
What the hell are you talking about? Mac OS X is Unix. Any decent Unix system ships with all the standard ISO C++ libraries. Mac OS X has done so from day 1. The Xcode developer tools ship with all the associated headers and the GNU compiler tools. If you have the tools installed, you can compile anything that is standard ISO C++. | Code: | #include <iostream> using namespace std; int main( void ) { int x; cout << "Test"; cin >> x; cout << x; return 0; } | Works fine for me. Stick it in a cpp file, run g ++ on it and, boom, done. (Edited by helloworld at 3:22 pm on July 17, 2005) |
|
|
Duekiller
|
Posted at 10:35 am on July 5, 2005 |
| Sorry to tell you this so late, but your problem is that the libaray that defines cin, is not on the mac because macs have diffrent libraries and shit so you need to grab the mac library (remember C++ is translated into ASSEMBER and then into machine code) |
|
|
ana
|
Posted at 9:11 am on June 18, 2005 |
| yeh i was fine when i tried it at work. the compiler i have is xtools or xcode which came on here... |
|
|
80Kidz
|
Posted at 8:59 am on June 18, 2005 |
| So it did work on your friends PC??? Well then it maybe the compiler you have. Did you get it off the internet somewhere??? |
|
|
ana
|
Posted at 8:55 am on June 18, 2005 |
| its really long but i have tested it on a PC its my f-ing mac! *throws it out the window*. |
|
|
80Kidz
|
Posted at 8:52 am on June 18, 2005 |
| Hmmm, well I don't understand whats going on... If it's possible....could you post the coding and I will test it on my PC...that's if its not too big... |
|
|
ana
|
Posted at 8:45 am on June 18, 2005 |
| the codes fine and everything i had my geek check it for me but it keeps comming up with errors when i put 'cin' or anything like that! |
|
|
80Kidz
|
Posted at 8:43 am on June 18, 2005 |
| I used to use C++ but I have a PC so I can't really help you.. Though what do you mean it "won't run"??? Are you using a test program to run it off of??? You're coding my have a bug in it....check it over once again... |
|
|
ana
|
Posted at 8:42 am on June 18, 2005 |
Quote: from Angel Of Death1337 at 11:41 am on June 18, 2005
Oh well you see mac sucks ass
yeh so do you... is there anyone that can actually help? |
|
|
Angel Of Death1337
|
Posted at 8:41 am on June 18, 2005 |
| Oh well you see mac sucks ass |
|
|
ana
|
Posted at 8:40 am on June 18, 2005 |
| i mean the code doesnt work when i try and run it... (Edited by ana at 11:42 am on June 18, 2005) |
|
|
Acathrines1
|
Posted at 8:39 am on June 18, 2005 |
what |
|
|
Most recent 15 of 16 previous replies displayed. |