V
Venkat
Hi All,
I want to typecast int to std::string how can i do it.
Here is the sample code.
int NewList[500];
//Fill the NewList with integers values.
.......
.......
//Replace the file contents with new list values at a specified location.
int i=0;
std::string line;
ifstream inFile(sample);//opens a file to read
while (getline (inFile, line) )
{
int comma1Pos = line.find(',');
int comma2Pos = line.find(',', comma1Pos+1);
int numChars = comma2Pos - comma1Pos - 1;
line.erase(comma1Pos+1, numChars); //
line.insert(comma1Pos+1, (std::string)NewList);
i++;
}
inFile.close();
In the above code the function insert takes 2nd argument as a string so i
was trying to type cast NewList to string.
The complier throws a type cast error saying type cast int to string is not
possible.
Is there any way i can type cast the same.
regards,
Venkat
I want to typecast int to std::string how can i do it.
Here is the sample code.
int NewList[500];
//Fill the NewList with integers values.
.......
.......
//Replace the file contents with new list values at a specified location.
int i=0;
std::string line;
ifstream inFile(sample);//opens a file to read
while (getline (inFile, line) )
{
int comma1Pos = line.find(',');
int comma2Pos = line.find(',', comma1Pos+1);
int numChars = comma2Pos - comma1Pos - 1;
line.erase(comma1Pos+1, numChars); //
line.insert(comma1Pos+1, (std::string)NewList);
i++;
}
inFile.close();
In the above code the function insert takes 2nd argument as a string so i
was trying to type cast NewList to string.
The complier throws a type cast error saying type cast int to string is not
possible.
Is there any way i can type cast the same.
regards,
Venkat