Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ cout without include iostream

std::cout "text here";
Comment

C++ cout iostream

#include <iostream> // for std::cout

//std::cout outputs Strings, numbers and variables to the commandline
int main()
{
  	int x = 1
    std::cout << "Hello" << " world!
" << x; 
  	/* 	outputs: Hello world!
		1 						*/
////////////////////////////////////////////////////////////////////////////////////  	
  	// cout does not make a new line for each call
  	std::cout << "The answere: ";
  	std::cout << 42;
  	/* 	outputs: The answere: 42 */
///////////////////////////////////////////////////////////////////////////////////  
  	// std::endl and 
 are both newlines
  	// std::endl adds a newline and makes sure the text gets displayed immediately
  	// "
" adds a newline.(cout makes it display immediately by default)
   	std::cout << "step1" << std::endl
      		  << "step2" << '
'
      		  << "end";
	/*	outputs: step1
    			 step2
                 end */
//////////////////////////////////////////////////////////////////////////////////
    return 0;
}

//The operator << gets overloaded by iostream to change its usage to what you see above
Comment

PREVIOUS NEXT
Code Example
Cpp :: string search c++ 
Cpp :: c++ check substring 
Cpp :: how to calculate bitwise xor c++ 
Cpp :: c #define 
Cpp :: iterate through list c++ 
Cpp :: how to initialize vector 
Cpp :: print two dimensional array c++ 
Cpp :: creare array con c++ 
Cpp :: macros in c++ 
Cpp :: c++ vector remove all duplicate elements 
Cpp :: c++ function as paramter 
Cpp :: find in unordered_map c++ 
Cpp :: cpp array init value 
Cpp :: c++ #include 
Cpp :: count number of prime numbers in a given range in c 
Cpp :: c++ class template 
Cpp :: c++ set swap 
Cpp :: c++ integer array 
Cpp :: c++ array pointer 
Cpp :: looping in map c++ 
Cpp :: int max in c++ 
Cpp :: loop c++ 
Cpp :: heredar constructor c++ 
Cpp :: matrix c++ 
Cpp :: square gcode 
Cpp :: variadic template in c++ 
Cpp :: balanced brackets in c++ 
Cpp :: how to find factorial of number in c++ 
Cpp :: compare function in c++ 
Cpp :: remove linked list elements leetcode 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =