I'm not too sure what you are trying to do, so if I'm wildly off forgive me.
Are you trying to count the number of spaces & tabs per line in a text file?
If so, maybe you could create a vector to hold the space and tab count of each line.....you could read each line with getline() then use the STL algorithm count_if() to count if each char is a space or char...like;
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
bool IsSpace(const char& c){
return c == ' ' || c == '\t';
}
int main(){
std::ifstream in;
std::vector<int> vec;
in.open("MyFile.txt");
if(!in.is_open()){
std::cout << "Error opening file";
return 1;
}
std::string str;
while(!in.eof()){
getline(in,str);
vec.push_back(std::count_if(str.begin(),str.end(),IsSpace));
}
std::cout << "Number of lines counted " << vec.size() << std::endl;
std::cout << "Number of spaces & tabs per line was;" << std::endl;
std::copy(vec.begin(),vec.end(),std::ostream_iterator<int>(std::cout,"\n"));
}