View Single Post
  #2 (permalink)  
Old March 17th, 2005, 10:41 AM
icopec icopec is offline
Authorized User
 
Join Date: Mar 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

//excuse my bad english in advance
//because I don't use it all the time
****************************
Object oriented programming
****************************
INPUT AND OUTPUT IN C++

INPUT
#include <iostream>
int main(){
int n; double d;
std::cin >> n >> d;
   return 0;
}

OUTPUT
#include <iostream>
int main(){
int n = 10;
std::cout << n << '*' << n << " je " << n*n;
   return 0;
}

MANIPULATORS:
ends (end of string)
endl (end of line)
flush (flushing the buffer)
setprecision (precision of real numbers)
setw (print width)
setbase (base of whole numbers 8, 10 or 16)
setfill (fill sign)
setiosflags (sets certain formats)(see: ios flags)
resetiosflags (resets given formats)(see: ios flags)

IOS FLAGS:
boolalpha (prints bool values as a string,else as number)
dec (decimal format for whole numbers)
fixed (floating point format for real numbers)
hex (hexadecimal fotmat for whole numbers)
internal (empty spaces between sign and number- or base mark)
left (left alignment)
oct (octal format for whole numbers)
right (right alignment)
scientific(exponential form for real numbers)
showbase (prefiks for base of a whole numbers)
showpoint (decimal point)
showpos (plus sign)
skipws (skipping whitespaces - spaces, tabs, ...)
unitbuf (buffer emptying after every input)
uppercase (upper letters A-F in heksadecimal view)

example:
#include <iostream>
#include <iomanip>
int main(){
double d = 123.456789;
std::cout << std::setiosflags(std::ios::scientific | std::ios::left);
std::cout << std::setprecision(9) << std::setw(20) << std::setfill('_');
std::cout << d << std::endl;
   return 0;
}
greetings from: CROATIA
posted by: icopec
Reply With Quote