-3

The problem I am encountering is the warning message I get when running the c++ .cpp code. Is there another way I can convert an integer to a string.

enter image description here

Here is a snapshot of the code I am running, and where the problem is:

string empId2 = to_string(empId);
2
  • 1
    Either your library doesn't support to_string (introduced with c++11), or you need to compile in c++11 standards mode or later (-std=c++11 on gcc and clang). Commented Oct 27, 2015 at 0:58
  • 1
    Don't link images. Copy and paste the text. Commented Oct 27, 2015 at 1:01

3 Answers 3

1

You are missing a header file. Check your #include directives. That one is gcc's standart warning for cases like that.

Sign up to request clarification or add additional context in comments.

Comments

0

This warning is shown when the function, in this case to_string is defined after it is used. Either move the definition of the function above or in a new file and include its header.

2 Comments

Why would he define to_string himself?
He doesn't have to, he can include <string>
-1

You can use std ostringstream to convert from any type to string e.g:

std::ostringstream oss;
oss<<empId;
string empIdStr = oss.str();

1 Comment

Not "any type", and you missed the point of using to_string.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.