Iomanip noskipws

I need to find the number of columns in a txt file like this:

col1 col2
34 12
24 65

This function well work in C++

#include <iostream>
#include <iomanip>
#include <fstream>

int n_colum(char name_file[]) {
   int col = 0;
   char c;
   ifstream f;
   f.open(name_file);
   f >> noskipws; //I have to count the whitespace, tabs, and return
   do{
        f >> c;
        if (c==\'t' || c==' ') col++;
    }while(c!='\n'); //I consider the finish of a col when there is a '\n'
   f.close();
   return col+1;
}

in root the function never stop. thanks.

Hi,

CINT does not (yet) properly pass noskipws to the stream.
In addition you code is lacking a few extra checks (to avoid the infinite running), you may want to consider to use:

For now, simply compile you script with ACLiC (adding a ‘+’ after your filename).

Philippe