C++/std

Advertisement


Question
Hi
i have a question about using std in c++ programming,for instance using 'std::cout' , 'std::cin' or 'std::endl'
could you plz give me a definition for std and tell me the function of std in using of it in code?

Thanx
Bita

Answer
http://www.cprogramming.com/tips/showTip.php?tip=42&count=30&page=0count=99order
http://www.cplusplus.com/reference/

Dear Bita:

As explained above, "The standard C++ library is a collection of functions, constants, classes, objects and templates that extends the C++ language providing basic functionality to perform several tasks, like classes to interact with the operating system, data containers, manipulators to operate with them and algorithms commonly needed."

cin and cout are used to input and print characters using a stream just like printf and scanf except you are using the operators << and >> to represent output and input respectively.

Here is an example of code using cin and cout:

#include<iostream>



int main()

{

   int age;

   

   std::cout<<"Enter your age: ";

   std::cin>>age;

   std::cin.ignore();  //remove the terminating character

   std::cout<<"You entered "<<age<<std::endl;

   

   std::cin.get();

   return 0;

}  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Titus B. Ledbetter, Jr.

Expertise

C , MFC, Object Oriented, Artificial Intelligence

Experience

I have over ten years experience in the field of Computer Science, five years experience developing C/C++. I recently wrote a chess program using Object Oriented, C++, MFC.

Education/Credentials
Master's Degree Computer Science from Johns Hopkins

©2016 About.com. All rights reserved.