LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 691 users online 174550 members 1514 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Video | Dictionary | News | FAQ
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
6 online / 34 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

C++
Replies: 16Last Post April 9, 2006 7:06pm by Misero
Pages: 1 2 Email Print Favorite
steel


Dairy Product Addict
Reply
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.

-------
Keep your friends close and your enemies closer...


11:05 am on July 20, 2005 | Joined May 2005 | 205 Days Active
Join to learn more about steel Maryland, United States | Straight Male | 558 Posts | 3781 Points
Misero


Dairy Product Addict
Reply
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)

-------
"I am against religion because it teaches us to be satisfied with not understanding the world."


7:06 pm on April 9, 2006 | Joined Sep. 2003 | 130 Days Active
Join to learn more about Misero United Kingdom | Straight Male | 696 Posts | 2013 Points
Pages: 1 2 Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic