Register for your free account! | Forgot your password?

You last visited: Today at 21:20

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++] I/O-Stream

Discussion on [C++] I/O-Stream within the Coding Tutorials forum part of the General Coding category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2007
Posts: 102
Received Thanks: 49
[C++] I/O-Stream

==========Input-/ Output-Stream classes==========

C++ got a new input-/output-stream which is based on classes.They are made available in their own library which is called iostream-library.
The image shows the class-hierarchy.



The class ios is the basis-class of all stream-classes.
The class istream was designed for the Reading.
The class ostream was designed for Writing.
In these istream and ostream classes are the operators << and >> defined.

Standard-Streams

  • cin : object is used for input ( istream )
  • cout : object is used for output ( ostream )
  • cerr : object is used for unbuffered error-outputs ( ostream )
  • clog : object is used for buffered error-outputs ( ostream )


==========Basics==========
Code:
#include <iostream>
using namespace std;

int main()
{
   cout << "Hello!I am a console application." << endl; 
   cout << "Please enter a number" << endl;
   int number;
   cin >> number;

   system("PAUSE");
   return 0
}
-console output is used for displaying the sentence Hello!I am a console application.
-the << and >> are the operators for output and input.
-endl is used for a line feed
-int number : numberr is declared as an integer.
-console input is used for the input.


==========Manipulator==========
Code:
// [b]showpos[/b] is used for displaying algebraic sign
cout << showpos << 123456789;   // output : + 123456789
//You can also use :
cout.setf( ios::showpos )
cout << 123456789;
//All following outputs positive numbers with algebraic sign
cout << 558;   // output : + 558


//Use [b]noshowpos[/b] to cancel the positive algebraic sign 
cout << noshowpos << 123456789   // output : 123456789
//You can also use :
cout.unsetf( ios::showpos )
cout << 123456789;
manipulators for formatting integers :
  • oct : octal notation
  • hex : hexadecimal notation
  • dec : decimal notation ( standard )
    -------------------------------------------------
  • showpos : positive integers are displayed with a algebraic sign
  • noshowpos : posituve integers are not displayed with a algebraic sign ( standard )
  • uppercase : hexadecimal notations are used with capital letters
  • nouppercase : hexadecimal notations are used without capital letters ( standard )

Example :

Code:
#include <iostream>
using namespace std;

int main()
{
   int number;
   cout << "Enter a number" << endl;
   cin >> number;
   
   cout << " octal : " << oct << number << endl;
   cout << " decimal : " << dec << number << endl;
   cout << " hexadecimal : " << hex << number << endl;

    system("PAUSE");
    return 0;
}
I gonna continue this tutorial later..Gonna play a little bit now

Opalis
Opalis is offline  
Reply


Similar Threads Similar Threads
One Piece Stream ?
06/07/2010 - Anime & Manga - 14 Replies
Hey Com. Wollte euch fragen ob ihr ne Seite kennt wo es gute One Piece Streams gibt . Danke im vorraus ;-)
Stream Help
03/21/2010 - Technical Support - 7 Replies
Hallo, ich habe mir vor paar Monaten mal einen Stream Account gemacht, nur habe ich den Code nicht erhalten wo ich Counter Strike Aktivieren konnte. Jetzt habe ich vor paar wochen mit css im laden gekauft und habe mir gleich nen neuen account erstelle. Jetzt kann ich leider nie abbrechen drücken, wenn er mit den falschen account einloggen möchte. Wie kann ich das ändern, das er sich damit nicht einloggt? screen liegt im anhang
WoW Stream
03/01/2009 - World of Warcraft - 4 Replies
Moin Moin Epvpler :) Gestern Abend habe ich doch endlich mal meinen Twink Mage auf 80 gebracht und mir ist dabei sofort eine Idee gekommen. Ich habe vor mit meinem Mage aktiv PvP zu betreiben, im Battleground und in der Arena. Ich habe dabei zwei Erfolge im Ziel: - Den Titel Kampfmeister - Den Titel Arenameister Manche werden sich nun denken "Schafft er doch nie" Oder "Ist doch bestimmt ein Noob".
3 new Videos [HQ Stream!]
11/01/2008 - Aion - 0 Replies
Here are some new Videos straight outta the new Open Beta Client. High Quality on a fast server. The DivX Webplayer is required. http://www.beta.envy-guild.de/video.html There are 2 fight scenes between Elyos and Asmodians and a tutorial that explains the interface. Ripped and provided by Vision, a member of the Envy Legion.
Bloodsport [Stream]
09/28/2008 - Off Topic - 5 Replies
Hallo :) Wollte seit langem mal wieder Bloodsport gucken ( Bloodsport 1 nicht 2,3, oder 4 ) und finde absolut keinen Stream und wollte nur fragen ob irgentwer von euch ne Seite hat wo Bloodsport ist, wenn ja bitte einfach posten. Danke schonmal gibt auch THX :)



All times are GMT +2. The time now is 21:20.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.