c++ char print fixed
C++
/*
OUTPUT
char variable value: Programming
-----------------------------------------------------
[%s] |Programming|
[%10s] |Programming|
[%15s] | Programming|
[%-15s] |Programming |
[%15.5s] | Progr|
[%-15.5s] |Progr |
-----------------------------------------------------
*/
// NOTE: Specifically used for char data-types (not strings)
char str[]="Programming"; // Length = 11
std::cout << "[%s] |";
printf("%s",str); // Display Complete String
std::cout << "|\n";
std::cout << "[%10s] |";
printf("%10s",str); // 10 < Length: Display Complete String
std::cout << "|\n";
std::cout << "[%15s] |";
printf("%15s",str); // 15 > Length: Displays Complete String with 4 spaces Alignment:Right
std::cout << "|\n";
std::cout << "[%-15s] |";
printf("%-15s",str); // Same as Above But Left Aligned
std::cout << "|\n";
std::cout << "[%15.5s] |";
printf("%15.5s",str); // 15-5 = 10 spaces and show first 5 characters Align : R
std::cout << "|\n";
std::cout << "[%-15.5s] |";
printf("%-15.5s",str); // 15-5 = 10 spaces and show first 5 characters Align : L
std::cout << "|\n";
Also in C++:
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- inconsequential meaning
- Category
- C++
- Title
- size of a matrix using vector c++
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- Given an undirected graph, count the number of connected components.
- Category
- C++
- Title
- erase in set
- Category
- C++
- Title
- count a character in a string c++
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- passing reference in c++
- Category
- C++
- Title
- double ended queue in c++ stl
- Category
- C++
- Title
- strchr function in c++
- Category
- C++
- Title
- c++ functions
- Category
- C++
- Title
- passing array to function in c++
- Category
- C++
- Title
- c++ movment
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- double to string c++
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- class in c++
- Category
- C++
- Title
- c++ char if
- Category
- C++
- Title
- Read multiple files(.txt) c++
- Category
- C++
- Title
- Find a element in a map C++
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- nginx linux
- Category
- C++
- Title
- c++ convert const char* to LPCWSTR
- Category
- C++
- Title
- c++ max of array
- Category
- C++
- Title
- c++ get last element in vector
- Category
- C++
- Title
- cloud hosting
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- unordered_map c++ insert
- Category
- C++
- Title
- vector concat c++
- Category
- C++
- Title
- assegnare valori in c++
- Category
- C++
- Title
- clear file before writing c++
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- level order traversal
- Category
- C++
- Title
- compare function in sort c++ stl
- Category
- C++
- Title
- git branch in my bash prompt
- Category
- C++
- Title
- c++ raw string
- Category
- C++
- Title
- how to ensure the user inouts a int and not anything else c++
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- count number of zeros in array in O(logN)
- Category
- C++
- Title
- c++ excel blank cells
- Category
- C++
- Title
- c++ program for matrix addition
- Category
- C++
- Title
- c++ for loop
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- lopping over an array c++
- Category
- C++
- Title
- newline in c++
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- typeid to string c++
- Category
- C++
- Title
- initialize map c++
- Category
- C++
- Title
- restting a queue stl
- Category
- C++
- Title
- c++ argv
- Category
- C++
- Title
- c++ vector pop_back
- Category
- C++
- Title
- call by reference c++ example
- Category
- C++
- Title
- c++ convert int to double
- Category
- C++
- Title
- retu7rn this c++
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- c++ function to find minimum element in array
- Category
- C++
- Title
- matrix class in c++
- Category
- C++
- Title
- how initilaize deffult value to c++ class
- Category
- C++
- Title
- c++ code for polynomial addition
- Category
- C++
- Title
- 2d vector
- Category
- C++
- Title
- Combination Sum
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- iterate 2d array c++
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++
- Title
- how to calculate trigonometric values in c++
- Category
- C++
- Title
- : error: ‘cont’ cannot be used as a function return (cont(cont-1))/2;
- Category
- C++
- Title
- string to number in c++
- Category
- C++
- Title
- input a string in c++
- Category
- C++
- Title
- what is a header in c++
- Category
- C++
- Title
- two elements with difference K in c++
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- C++ string format ctime
- Category
- C++
- Title
- initialising 2d vector
- Category
- C++
- Title
- Arrays hackerrank solution in c++
- Category
- C++
- Title
- how to make a switch case statement in c++
- Category
- C++
- Title
- how use global variables instead of local in c++
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- C++ remove element from set
- Category
- C++
- Title
- gfg right view of tree
- Category
- C++
- Title
- expected initializer before 'isdigit'|
- Category
- C++
- Title
- c++ map insert
- Category
- C++
- Title
- flushing output in c++
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- heap sort
- Category
- C++
- Title
- how to show c++ binary files in sublime text
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- variadic templates
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- c++ rainbow text
- Category
- C++
- Title
- check an stack is empty c++
- Category
- C++
- Title
- std::substring
- Category
- C++
- Title
- c++ empty stream
- Category
- C++