Some little help over a small program :)

Hi there!im trying to make a program that reads characters and convert spaces in the text into tab.i mean,if there are 7 spaces,i put 1 tab and 3 spaces! but i cant make it work!
#include <iostream>
#include <fstream>
using namespace std;
int main(){
int flag,i,count=0;
char c,temp;
ifstream myfile ("a.txt");
while (myfile.is_open())
{
while ( myfile.good())
{
c=myfile.get();
if (c!=' ')
{cout<<c;}
else
{count++;
c=myfile.get();
while (isspace(c))
{count++;
c=myfile.get();
if (count==4)
{cout<<'\t'; //if i put here "TAB" it will be printed!?!!
count=0;}
}
if (count!=0)
{for (i=0;i<count;i++)
{cout<<" ";}
cout<<c;
count=0;}}}}}
i dont understand what might be happening..
sorry for my bad english :P
Topic archived. No new replies allowed.