Friday, 22 June 2012

program-52


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
FILE *fp;
char str[11],ch;
int i=0;
clrscr();
fp=fopen("a.txt","at");
fp=fopen("a.txt","r");
if(fp==NULL)
{
printf("\n cannot open");
exit();
}
printf("the each word in reverse order :\n");
while((ch=getc(fp))!=EOF)
{
if(ch=='\n'||ch==' ')
{
str[i]='\0';
strrev(str);
printf("%s ",str);
i=0;
}
else
str[i++]=ch;
if(ch=='\n')
printf("\n");
}
fclose(fp);
getch();
}
/*
Type EXIT to return to Turbo C++. . .Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

C:\TC\BIN>copy con a.txt
peer saab
nadaf das
sad
^Z
        1 file(s) copied.

C:\TC\BIN>exit
the each word in reverse order :
reep baas                                                                      
fadan sad                                                                      
das                                                                            
*/

No comments: