Solved write copy command on c programming

July 3, 2011 at 04:59:00
Specs: Windows 7
I want to write a copy command in C programming to copy one text file.

Thanks...


See More: write copy command on c programming

Report •

✔ Best Answer
July 10, 2011 at 22:57:57
Void main()
{
FILE *fp,*fp1;
char c;

fp=fopen("source","r");
fp1=fopen(" destination","w");


while((c=getc(fp))!=EOF)
putc(c,fp1);
fclose(fp1);
fclose(fp);
}


Cegonsoft



#1
July 3, 2011 at 07:38:17
Very interesting. You will find it most instructive. Let us know when you have finished.

Report •

#2
July 4, 2011 at 02:48:09
I mean I don know how to write it, so I post it here to ask for help....

Report •

#3
July 4, 2011 at 04:49:22
I can only think that:

1. You have need of such a program.

2. You are teaching yourself to program.

3. This is a homework question.

In which case:

1. There are plenty of programs to do this already. Just use the "copy" command.

2. Do a little reading; it's the only way that you will learn.

3. As 2.


Report •

Related Solutions

#4
July 6, 2011 at 04:04:53
Thz... I know. I will try and mayb need some help from you.

Thanks in advances...


Report •

#5
July 10, 2011 at 22:57:57
✔ Best Answer
Void main()
{
FILE *fp,*fp1;
char c;

fp=fopen("source","r");
fp1=fopen(" destination","w");


while((c=getc(fp))!=EOF)
putc(c,fp1);
fclose(fp1);
fclose(fp);
}


Cegonsoft


Report •

#6
July 13, 2011 at 07:15:27
Thanks a lot for your help....

Report •

#7
July 13, 2011 at 09:46:37
Wanna ask how can I show the content of the file on the screen.

Which command should I use?? printf?


Report •

#8
July 13, 2011 at 16:15:52
Shouldn't your var to determine EOF be of type int? Check your files against NULL before trusting that they're open. main should return a value to the OS.

To output to screen

printf("%c", variable)
or maybe
putchar(variable)

if you write the output file and to screen, wrap the while loop in braces. while(...) { ... }


Report •

#9
July 13, 2011 at 19:18:34
Finally, I can run it.

Thanks a lot for all friends here.....

Thanks for your contribution..


Report •

Ask Question