Here is my code:
#include <iostream> using namespace std; int main(){ char inp[5], out[4]; cin >> inp >> out; cout << inp << endl; cout << out << endl; system("pause"); return 0; }
when I type:
12345 6789
It gives me:
6789
Why I failed to save the 5 words char array ‘inp’ and it showed nothing? The second input looks normal though. However, when I set out[3] or out[5], it seems to work alright? It seem that two char array of [5] then followed by [4] would cause problem…
Related Posts:
- Using cin to input a single letter into a char
- How to convert a char array to a string?
- Comparing the values of char arrays in C++
- C++ 2d char array to string
- How to dynamically allocate arrays in C++
- How to dynamically allocate arrays in C++
- outputting ascii table in C++
- std::string to char*
- How do I find the length of an array?
- Conversion from string to char – c++
- Initializing an array of objects
- Passing an array by reference
- Return array in a function
- What is an unsigned char?
- Passing an array by reference
- What is the array form of ‘delete’?
- Use new operator to initialise an array
- How do I declare a 2d array in C++ using new?
- std::cin.getline( ) vs. std::cin
- lvalue required as left operand of assignment – Array
- C++ round a double up to 2 decimal places
- When and why do I need to use cin.ignore() in C++?
- How to convert a single char into an int [duplicate]
- std::string to char*
- Is there a function to copy an array in C/C++?
- How to convert a std::string to const char* or char*
- Cleanest way to copy a constant size array in c++11
- Reverse Contents in Array
- C++ error: “Array must be initialized with a brace enclosed initializer”
- Why would we call cin.clear() and cin.ignore() after reading input?
- warning: ISO C++ forbids variable length array
- cin >> “no operator matches these operands”
- c++ array – expression must have a constant value
- getline() does not work if used after some inputs
- Passing a 2D array to a C++ function
- Press Enter to Continue
- How can I convert const char* to string and then back to char*?
- cin >> “no operator matches these operands”
- Correct way to use cin.fail()
- Static array vs. dynamic array in C++
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- Checking cin input stream produces an integer
- Convert char* to string C++
- Fill array with random numbers within a specified range (C++)
- Remove an array element and shift the remaining ones
- Reading getline from cin into a stringstream (C++)
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- How to add element to C++ array?
- How to convert vector to array
- How to find the size of an int[]?
- C++: Expression must have a constant value when declaring array inside function
- splitting a string into an array in C++ without using vector
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- Printing an array in C++?
- Delete 2D array C++
- How do you initialise a dynamic array in C++?
- C++ array assign error: invalid array assignment
- How to add element to C++ array?
- Reading from .txt file into two dimensional array in c++
- std::cin input with spaces?
- extended initializer lists only available with
- Creation of Dynamic Array of Dynamic Objects in C++
- how to initialize an empty integer array in c++
- Check if C++ Array is Null
- Correct way to work with vector of arrays
- Resizing dynamic array in c++
- C++ Initializing a Global Array
- Dynamically allocated string array, then change it’s value?
- Convert char array to single int?
- How can I assign an array from an initializer list?
- How do I flush the cin buffer?
- How do I return a char array from a function?
- creating an array of structs in c++
- Reading data from file into an array
- How to read lines of text from file and put them into an array
- Why can’t we pass arrays to function by value?
- Double pointer array in c++
- C++ pass an array by reference
- cin.ignore(numeric_limits
::max(), ‘\n’) - How to sort with a lambda?
- How to memset char array with null terminating character?
- casting int to char using C++ style casting
- creating dynamic array of string c++
- creating an array of structs in c++
- C++ Array of pointers: delete or delete []?
- too many initializers for ‘int [0]’ c++
- C++ correct way to return pointer to array from function
- Warning: comparison of distinct pointer types
- how to find 2d array size in c++
- How do I simply compare characters in C++?
- Getting error “array bound is not an integer constant before ‘]’ token”
- Multiple inputs on one line
- Different ways to deallocate an array – c++
- Is C++ Array passed by reference or by pointer?
- Proper way to pass dynamic arrays to other functions
- Array of Linked Lists C++
- C++ float array initialization
- IntelliSense: the object has type qualifiers that are not compatible with the member function
- What is the meaning of a C++ Wrapper Class?
- Is null reference possible?