-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);
MD XF
  • 7,860
  • 7
  • 40
  • 71
Dler Ari
  • 21
  • 1
  • 10

3 Answers3

1

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

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.

Justice
  • 290
  • 2
  • 7
-1

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

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