D
D
Denius (genius)2018-11-26 12:42:53
C++ / C#
Denius (genius), 2018-11-26 12:42:53

Why does this code work in Visual Studio but not in Code::Blocks?

#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  s = to_string(123);
  cout << s;

  return 0;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2018-11-26
@Conan_Doyle_SBINH

Firstly. "Doesn't work" is usually followed by some kind of error. And it must be applied to the question.
Secondly, it is important not in which IDE, but which compiler is used.
Wangyu that they are different for you, with different support for standards.

P
Pavel, 2018-11-26
Yazovskikh @unepic

I turn on the psychic mode. Because std::to_string was introduced in C++11, while your Code::Blocks uses gcc without -std=c++11. But it is better to write what error messages you have.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question