the data
test.txt
12,45,60,90
13,70,1,2
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include<vector>
#include <stdlib>
using namespace std;
int main(){
vector <string> record;
ifstream infile( "test.txt" );
while (infile)
{
string s;
if (!getline( infile, s )) break;
istringstream ss( s );
while (ss)
{
string s;
if (!getline( ss, s, ',' )) break;
record.push_back( s );
}
int number_string = record.size();
int convertInt[number_string];
for(int i=0;i<number_string;i++){
cout<<record[i]<<" ";
}
for(int a=0;a<number_string;a++){
convertInt[a] = atoi(record[a]); //error std::allocator<char> >' to `const char*' for
// argument `1' to `int atoi(const char*)'
}
}
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 18 January 2011 - 04:53 AM

New Topic/Question
Reply




MultiQuote






|