You have assigned a ' ' (space) to a variable called 'space'. And what you are doing here is isspace(space). The variable space ALWAYS has the value ' ' means isspace(space) will always be true and therefore ( !isspace(space) ) will ALWAYS be false.
Therefore I don't really get what you are trying to achieve with the code
1 2 3 4 5
if(!isspace(space))
{
getline(infile, line);
outfile << line <<endl;
}
Why don't you try this instead?
1 2 3 4 5
while(!infile.eof())
{
getline(infile, line);
outfile << line <<endl;
}
But I don't think it will solve
align it to the left margin and then output it on the file
What you have to do is to remove the white spaces from the string variable "line" before you output to the file.
1 2 3
getline(infile, line);
// Place your code to remove white spaces from "line"
outfile << line <<endl;