c++ - Counting columns of a space separated file -


I need to use std :: count (or any other appropriate work) in my question Is the column of files different from any location

I currently use something like this:

  std :: ifstream infix ("file"); Int lines = std :: count (std :: istreambuf_iterator & lt; char> (inFile), std :: istreambuf_iterator & lt; char & gt; (), '\ n');  
  std :: ifstream infix ("file"); Int columns = std :: count (std :: istreambuf_iterator & lt; char> (inFile), std :: istreambuf_iterator & lt; char & gt; ('\ n'), '') + 1;   

What do I want?

Edit:

I mean, if the data like "in file" is 1 2 or 1 [many spaces here] 2 , anyway column should be 2 or 2 anyway?

No, you will calculate the space, not the column. You have to do your line to Tokunize, eg. By

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -