I want to squeeze multiple lines in a single line. I have tried to apply my own logic but there is something wrong.
char *p;
linecount=0;
while (fgets(buffer, sizeof(buffer), file))
{
//it will print the user input with number
p=buffer;
if('\r' == *p ||'\n' == *p )
{
linecount++;
if(linecount>2 )
printf("\n");
}
else
{
linecount=0;
printf("\t %s", p);
}
For instance a file has lines like
a
b
c
d
e
then the output should be
a
b
c
d
e
Basically, I am devloping a code for cat -s command.