cin src

A

America01

Hello, I am new to C++ and I had a question I couldn't seem to find a
answer to. I want to see the source of cin, I am running Linux and I
went into /usr/include and didn't find anything retaining to cin. Is
there even a source file for cin? I would assume so since it's a
function...

Thanks for your time.
 
N

Neelesh Bodas

Hello, I am new to C++ and I had a question I couldn't seem to find a
answer to. I want to see the source of cin, I am running Linux and I
went into /usr/include and didn't find anything retaining to cin. Is
there even a source file for cin? I would assume so since it's a
function...

Thanks for your time.

The contents of istream class can be seen in <iostream> header. Its
declaration can be found in <iostream>
extern istream cin;

The contents of class istream can be found in header <istream>. class
istream is actually a typedef.
typedef basic_istream<char> istream

-N
 
N

Neelesh Bodas

The contents of istream class can be seen in <iostream> header. Its
declaration can be found in <iostream>
extern istream cin;

Typo. Meant this -

cin is an object of istream class. The declaration of cin can be
found in <iostream> header.
extern istream cin;

-N
 
S

Stuart Redmann

Hello, I am new to C++ and I had a question I couldn't seem to find a
answer to. I want to see the source of cin, I am running Linux and I
went into /usr/include and didn't find anything retaining to cin. Is
there even a source file for cin? I would assume so since it's a
function...

If you want to use 'cin' as a programmer, you should not care much about it,
'cin' is just there. You should be aware that cin, being an istream-object, is
just an interface that you can use to retrieve data. What the actual source of
the data is, depends on how the executable/binary on your system had been
launched (for example the user may have 'piped in' the contents of a file). Thus
it is up to C++ run-time environment to provide you with the proper object
behind 'cin' (which would be either a ifstream or some other stream that is tied
to the console). This is all very platform dependent, and thus off-topic in this
newsgroup.

As a user of 'cin' you should write code that does not depend on which data
source for 'cin' is actually used.

Regards,
Stuart
 
D

Dan Noland

Hello, I am new to C++ and I had a question I couldn't seem to find a
answer to. I want to see the source of cin, I am running Linux and I
went into /usr/include and didn't find anything retaining to cin. Is
there even a source file for cin? I would assume so since it's a
function...

Thanks for your time.

My debian install does have the source for iostream. It is located in /
usr/include/c++/4.1.3/iostream

According to dpkg this file was installed by the package libstdc+
+6-4.1-dev. You may need to install the libstdc++ development package
for your distribution/compiler in order to mess with it. As previous
posters have mentioned, this is strongly advised against. Any error
you might see in istream is almost certainly the result of the misuse
of an istream object and NOT a bug in the standard c++ library.

If you are just curious what is in there, and you should be, then look
here:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/iostream-source.html
and here
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/istream-source.html

YT,
Dan Noland
http://nolandda.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,008
Latest member
KieraMcGuf

Latest Threads

Top