Hello,
I have a text file, and I want to read the first line and store it in a variable, and then read the second store it in a variable
I have tried to use stringstream function to convert string to integer but when i used this fonction twice i have the error:
error: redeclaration of `std::stringstream convert'
error: `std::stringstream convert' previously declared here
this is the code
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <fstream>
#include <sstream>
using namespace std;
int main ()
{
int y_size,x_size,num_comps_v;
//ouverture du fichier
ifstream infile;
infile.open ("test.txt");
if(infile)
{
string result1;
getline(infile,result1);
stringstream convert (result1);
if (!(convert >>num_comps_v))
num_comps_v=0;
string result2 ;
getline(infile,result2);
stringstream convert (result2);
if (!(convert >>y_size))
y_size=0;
}
the error is
error: redeclaration of `std::stringstream convert'
error: `std::stringstream convert' previously declared here
Could you help me please?
-----