What your teacher said is not true. cin
will not “break”. It’s just that formatted extraction into an std::string
is designed to read word by word. That’s intentional. It’s not broken.
As for your error, your call to std::getline
is broken because the delimiter argument has the wrong type. '\n'
is a char
literal; "\n"
is a char
array literal, not at all what you wanted.
Related Posts:
- What is the effect of extern “C” in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is `CString`?
- Difference between != and =! with an example(in C++)
- Unresolved external symbol in object files
- How do sizeof(arr) / sizeof(arr[0]) work?
- rand() between 0 and 1
- how to implement Interfaces in C++?
- What exactly is nullptr?
- How to make a SIMPLE C++ Makefile
- finding dll for “The specified module could not be found”
- no matching function for call to ‘ ‘
- 1e-9 or -1e9, which one is correct?
- Returning an empty string : efficient way in c++
- invalid conversion from ‘const char*’ to ‘char*’
- Evaluate a string with a switch in C++ [duplicate]
- Expected initializer before function name
- Inheriting constructors
- Pass a vector by reference C++
- lvalue required as left operand of assignment – Array
- What is uintptr_t data type
- Why do we use volatile keyword? [duplicate]
- C++ round a double up to 2 decimal places
- Windows 7 exception code: 0xc0000409
- Convert float to std::string in C++
- “items list” or “item list”
- When and why do I need to use cin.ignore() in C++?
- What does int & mean
- Evaluate a string with a switch in C++ [duplicate]
- “&” meaning after variable type
- undefined reference to ‘std::cout’
- warning: control may reach end of non-void function
- Error at constructor : Expected an identifier?
- identifier “string” undefined?
- What does LPCWSTR stand for and how should it be handled with?
- A warning – comparison between signed and unsigned integer expressions
- How can I convert const char* to string and then back to char*?
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- Reading integers from file and store them in array C++ [closed]
- Uninitialised value was created by a stack allocation
- C++ Image Processing Libraries
- Printing the correct number of decimal points with cout
- error C2011: ” : ‘class’ type redefinition
- error: request for member ‘..’ in ‘..’ which is of non-class type
- Socket API or library for C++?
- Initialize empty vector in structure – c++
- C++ catching all exceptions
- error: new types may not be defined in a return type
- error: passing ‘const …’ as ‘this’ argument of ‘…’ discards qualifiers
- Printing an array in C++?
- Appending a vector to a vector
- C++ Expression must have pointer-to-object type
- C++ “Access violation reading location” Error
- Getting error: ISO C++ forbids declaration of with no type
- IntelliSense: the object has type qualifiers that are not compatible with the member function
- codingbat-like site for C++
- extra qualification error in C++
- RPN Calculator for C++
- How can I get the list of files in a directory using C or C++?
- How do you make a HTTP request with C++?
- Error: C2228: left of ” must have class/struct/union
- error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
- Multi-character constant warnings
- How do I check if a C++ std::string starts with a certain string, and convert a substring to an int?
- How do I get the type of a variable?
- What is the meaning of a C++ Wrapper Class?
- terminate called after throwing an instance of ‘std::out_of_range’ what(): basic_string::substr
- error C2106: ‘=’ : left operand must be l-value
- What does it mean that “a declaration shadows a parameter”?
- error C2601: ‘main’ : local function definitions are illegall – MS VS 2013 Compiler
- std::string length() and size() member functions
- How to convert QString to int?
- Update GCC on OSX
- Which is faster C++ String length() or size()?
- creating an array of structs in c++
- How to read lines of text from file and put them into an array
- Undefined reference to class constructor, including .cpp file fixes
- Why can’t we pass arrays to function by value?
- multiple definitions error in c++ and solution to solve this issue
- Function stoi not declared
- How to draw line in OpenGL?
- c++ sizeof( string )
- How can I add reflection to a C++ application?
- Error: member function may not be declared outside of its class.
- Struct inheritance in C++
- How do I simply compare characters in C++?
- How to Check the Version of my gcc?
- Difference between function arguments declared with & and * in C++
- C++ floating point to integer type conversions
- How to get an average in C++?
- C++: variable ‘std::ifstream ifs’ has initializer but incomplete type
- template argument 1 is invalid (Code::Blocks Win Vista) – i don’t use templates
- invalid use of template name without an argument list
- What is “error C2061: syntax error : identifier “?
- What is the size of sizeof(vector)? C++
- The tilde operator in C
- Game Engines that use PHP for scripting?
- Link error “undefined reference to `__gxx_personality_v0′” and g++ [duplicate]
- How to use bitmask?
- -Error reading characters of string