Transformation from int to char*...

Hello

When i try to compile this program, it shows me this:
1
2
conturi.cpp: In function `int main()': conturi.cpp:16: `to_string' undeclared (first use this function)
conturi.cpp:16: (Each undeclared identifier is reported only once for each function it appears in.)


How can i fix this problem?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
 int main ()
 {
 	ifstream f("conturi.in");
 		ofstream g("conturi.out");
 	int N,X,max=0;
	 f>>N >>X;
	 int conturi[N];
	 
	 for (int i=0;i<N;++i)
	 {
	 	f>>conturi[i];
	 	
		 string cifra=to_string(conturi[i]);
	 	
		 char const*pcifra=cifra.c_str();
	 	
		 if ((*(pcifra)==X)&&(*(pcifra+1)==1))
	 	
		 {conturi[i]=conturi[i]-100000*cifra[0]-10000;
	 	
		 if (conturi[i]>max){
		 
		 max=conturi[i];}
	    }
	}
	 	
 	g<<max;
 	
 	
 	f.close ();
 		
 	g.close ();
 	return 0;
 }

Make sure you are compiling in C++11 mode and that your compiler is up-to-date enough to support std::to_string.
also, you shouldnt do variable size arrays until c++14 compliant compilers are out
Topic archived. No new replies allowed.