clanguage07@gmail.com

clanguage07@gmail.com

Saturday, June 16, 2012

Write a cprogram which copies one file to another?

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char file1[30],a[50],s[50],n;
    int j=0,k,i,len;
    FILE *fp;
    clrscr();
    printf("enter the file path:");
    gets(file1);
    fp=fopen(file1,"r");
    if(fp==NULL)
    {
        puts("file cannot be opend");
        exit(0);
        }
    printf("\n Enter the number of characters to reverse:");
    scanf("%d",&k);
    n=fread(a,1,k,fp);
    a[n]='\0';
    len=strlen(a);
    for(i=len-1;i>=0;i--)
    {
        s[j]=a[i];
        printf("%c",s[j]);
        j=j+1;
        }
    s[j+1]='\0';
    getch();
    }

No comments:

Post a Comment

GET MORE INFORMATION

http://ads.qadservice.com/t?id=c2168e05-8974-4816-872a-91936ff7379d&size=1024x768&drct=true