Code:
#include <iostream.h>
#include <fstream.h>
#include <ctype.h>
//no need for that large of a buffer. If buffers really have to be that big, consider dynamic strings.
int main()
{
char c;
ifstream fin;
ofstream fout;
fin.open("C:\\windows\\system32\\shell32.dll", ios::nocreate | ios::in);
fout.open("hello.txt", ios::out);
while(fin.get(c)) //this will keep going until it has no more chars to grab, i.e. EOF
{
if(c!=' ') //if its not a space, go ahead and output it
fout<<c;
}
fout.close(); fin.close(); //because its better
return 0;
}
If all your trying to do is remove just spaces...
oh and I believe the reason your getting only a fraction of your file is because that file is NOT filled with alphanumeric characters. Very few are...
if you want to copy over all alphanumeric...
Code:
int main()
{
char c;
ifstream fin;
ofstream fout;
fin.open("C:\\windows\\system32\\shell32.dll", ios::nocreate | ios::in);
fout.open("hello.txt", ios::out);
while(fin.get(c)) //this will keep going until it has no more chars to grab, i.e. EOF
{
if(isalnum(c))
fout<<c;
}
fout.close(); fin.close();
return 0;
}
-LC