I am trying to write a program to parse a file and look for spaces and store them in an array
then I want to make a new file with the format:
[spaces number on this line] (rest of line without spaces)
but all I want to do now is just store the values in the array
Here is what I have here but the allocation of spaces into the array isn't working right.
any ideas, if at all possible avoid a complete program, I want this mostly to be my own work, just a little help or idea would be nice though.Code:#include <iostream.h> #include <fstream.h> #include <stdlib.h> int main(int arc, char* argv[]) { int count=0; int spaces[256]; char a[256]; ifstream myfile; myfile.open("c:\\luke\\test.txt"); if(myfile.fail()) { cerr<<"you fool!\n"; abort(); } for(int i=0;i<=256;i++) spaces[i]=0; while(myfile.get(a)) { for(count=0;count<=sizeof(a);count++) if(a[count]==' '||a[count]=='\t') spaces[count]++; } for(i=0;i<=10;i++) cout<<spaces[i]<<endl; return 0; }



LinkBack URL
About LinkBacks


