Hello Nino,
your code is:
1 2 3 4 5 6 7 8 9 10
|
while (!infile.eof())
{
infile >> c;
if ( c > 32 || c < 126)
;
else
infile.clear();
infile.open("plaintext.txt");
infile >> c;
}
|
this is bad approach IMO.
first line should be like this:
1 2 3 4
|
while (infile.good())
{
///....
}
|
that way you know that while loop will break for any kind of error, not just EOF
next this code:
1 2 3 4
|
else
infile.clear();
infile.open("plaintext.txt");
infile >> c;
|
not sure but it looks like a bad boy.
else statement should be enclosed with brackets I think?
1 2 3 4 5 6
|
else
{
infile.clear();
infile.open("plaintext.txt"); // file handle should be closed before reopening ?
infile >> c;
}
|
Not sure if that was your intention but you're overriding c variable.
so when while loop finishes your function returns what?
only last character, not all of them sorted!
according to your comment in the code the function is supposted to return a const char*
But in that case your c varaible should be defined outside the function or you should create a heap pointer to the char* and return that.
also in your main function,
int getKey();
are you declaring a function inside a main() ?