Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22040

Difference Between GCC (G++) compiler and visual c++ compiler when using std::getline function [duplicate]

$
0
0

I was playing around with some code for reading lines from cin into strings that my gf gave me, and I noticed that in visual c++ std::getline() requires #include <string>, while in GCC (g++) it does not require #include <string>. What is the reason for this?

Example:

This works in g++ but not Visual c++:

#include <iostream>

int main() {
    std::string test;
    std::getline(std::cin, test);
    return 0;
}

This works in Visual c++ (and g++):

#include <iostream>
#include <string>

int main() {
    std::string test;
    std::getline(std::cin, test);
    return 0;
}


Viewing all articles
Browse latest Browse all 22040

Trending Articles