C ++ problems using cout and cin on the same line (xcode8)

Using Xcode with C ++ I am trying to create a simple console application. However, my use of cout and cin does not seem to work as I expect.

I expect:

Testing: 12
input was 12

edit: I cut the code as much as possible:

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    int num;
    std::cout << "Testing: ";
    std::cin >> num;
    std::cout << "input was " << num << std::endl;

    return 0;
}

Output Example:

12
Testing: input was 12
Program ended with exit code: 0

Am I missing something here?

+4
source share
1 answer

Apparently this is a problem with C ++ streams in the Xcode debugger, the Debug assembly.

Try the following:
1. Project → Change the active target ...
2. Search for the “preprocessor” in Build
3. Delete the values:
Preprocessor macros =_GLIBCXX_DEBUG=1 _GLIBCXX_DEBUG_PEDANTIC=1

, Xcode 3.2.1 ++ !

:
( #include):

#define _GLIBCXX_FULLY_DYNAMIC_STRING 1
#undef _GLIBCXX_DEBUG
#undef _GLIBCXX_DEBUG_PEDANTIC
+1

Source: https://habr.com/ru/post/1673533/


All Articles