Calculating sums of columns in CSV file using C++ -


How can I count the column amount from a CSV file using C ++?

My CSV file ago 22 45 33 8 50 70 4 60 88

And I want to do something like this in a array <

Text ">
  #include & lt; Iostream & gt; # Include & lt; Fstream & gt; Int main (int argc, char * argv []) {std :: ifstream in; Int array [3] = {0, 0, 0}; If (RGCC & lt; 2) return 1; In.open (argv [1], std :: ifstream :: in); While (in.good ()) {int one, two, three; In & gt; & Gt; One & gt; & Gt; Two & gt; & Gt; three; Array [0] + = one; Array [1] + = two; Array [2] + = three; } Std :: cout & lt; & Lt; Array [0] & lt; & Lt; '' & Lt; & Lt; Array [1] & lt; & Lt; '' & Lt; & Lt; Array [2] & lt; & Lt; Std :: endl; In.close (); Return 0; }   

Something like this?

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -