#Incorrect output

9 messages · Page 1 of 1 (latest)

magic orchidBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

main marsh
#

cin stops reading when it encounters a ' '

#

getline would be better suited for this

magic orchidBOT
#
template<
    class CharT,
    class Traits,
    class Allocator>
std::basic_istream<CharT, Traits>& getline(
    std::basic_istream<CharT, Traits>& input,
    std::basic_string<CharT, Traits, Allocator>&
        str,
    CharT delim);
// ... and 3 more
Defined in
main marsh
#

Also, I’m contractually obligated to reproach you for using using namespace std;

magic orchidBOT
#
Why Is `using namespace std` Considered Bad Practice?

using namespace std will import all of the symbols from std into the enclosing namespace. This can easily lead to name collisions, as the standard library is filled with common names: get, count, map, array, etc.
A key concern with using namespace std; is not what is imported now but rather what may suddenly be imported in the future.
While using namespace std; is alright for tiny projects, it is important to move away from it as soon as possible. Consider less intrusive options, if you insist on not using scope resolution:

// OK: *only* import std::vector
using std::vector;
// OK: namespace alias
namespace chr = std::chrono;
chr::duration x; ```
main marsh
#

cin >> myString only reads a single word, getline(cin, myString) will read a whole line

magic orchidBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

main marsh
#

❤️