M
Maxx
Here i have a program which was supposed to do the following:
Example INPUT:::
Dolorian refused to release the
lyrics for the track 'A Part Of Darkness'
on 'When All The Laughter Has Gone',
and several parts of the lyrics on almost
Example OUTPUT:::::
Dolorian refused to release the
Lyrics for the track 'A Part Of Darkness'
On 'When All The Laughter Has Gone',
And several parts of the lyrics on almost
What this program does is basically checks the first letter of every
line and changes it to upper case.
Here is the program:::::
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define BUFFER 5000
int main(int argc, char **argv)
{
FILE *fp;
int a[BUFFER];
int ch,*p=a,*c=a;
if((fp=fopen(argv[1],"a")) == NULL)
{
fprintf(stderr,"%s can't open file %s",argv[0],argv[1]);
exit(1);
}
while((ch=getc(fp))!=EOF)
{
*p++=ch;
}*p='\0';
for(;*c!='\0';c++)
{
if(*c==10 || *c==13)
{
++c;
if(islower(*c))
{
*c=toupper(*c);
}
}
}
while(*c++!='\0')
{
putc(*c,fp);
}
fclose(fp);
return 0;
}
It's get compiled with zero error/warning but when i run it against
any file it produces no output or change.The input remains the
same.please help i'm having tough time solving it.
Example INPUT:::
Dolorian refused to release the
lyrics for the track 'A Part Of Darkness'
on 'When All The Laughter Has Gone',
and several parts of the lyrics on almost
Example OUTPUT:::::
Dolorian refused to release the
Lyrics for the track 'A Part Of Darkness'
On 'When All The Laughter Has Gone',
And several parts of the lyrics on almost
What this program does is basically checks the first letter of every
line and changes it to upper case.
Here is the program:::::
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define BUFFER 5000
int main(int argc, char **argv)
{
FILE *fp;
int a[BUFFER];
int ch,*p=a,*c=a;
if((fp=fopen(argv[1],"a")) == NULL)
{
fprintf(stderr,"%s can't open file %s",argv[0],argv[1]);
exit(1);
}
while((ch=getc(fp))!=EOF)
{
*p++=ch;
}*p='\0';
for(;*c!='\0';c++)
{
if(*c==10 || *c==13)
{
++c;
if(islower(*c))
{
*c=toupper(*c);
}
}
}
while(*c++!='\0')
{
putc(*c,fp);
}
fclose(fp);
return 0;
}
It's get compiled with zero error/warning but when i run it against
any file it produces no output or change.The input remains the
same.please help i'm having tough time solving it.