MY PROGRAM IS NOT OUTPUTTING ANYTHING ON THE OUTPUT FILE

*****************************************************************************************************************************************************************************************************************
Last edited on
1
2
3
4
5
6
7
8
9
10
char next, space = ' ';
//...
     while(!infile.eof())
     {
        if(!isspace(space)) //false
        {
            getline(infile, line);
            outfile << line <<endl;
        }
     }
Hi ne555, i don't understand what you are trying to say. can you elaborate a bit?
Last edited on
The condition is always evaluated as false. You are asking if ' ' is an space.
**************************************************************************************************************************************
Last edited on
That's fine, but look at what you are using as argument of the function.
¿when did the variable 'space' change its value?
What do you propose would be a solution for my problem?
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;
Topic archived. No new replies allowed.