unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > C and C++

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2007, 12:20 PM
Neo_Reloaded Neo_Reloaded is offline
Tutorial Admin
 
Join Date: Dec 2006
Posts: 259
Default (C) File copy function

By Chernobyl

Here is a little function that copys one file to another location, a member of my forum requested this so i thought i would give it a go . Here is a little demo application using the function

Code:
#include <stdio.h>

void fileCopy(char* originalFile, char* newFile)
{
	FILE *inFile;
	FILE *outFile;
	char buffer[1000];

	inFile = fopen(originalFile, "rb");
	outFile = fopen(newFile, "wb");

	while(fread(buffer, 1, sizeof(buffer), inFile))
	{
		fwrite(buffer, 1, sizeof(buffer), outFile);
	}
	fclose(inFile);
	fclose(outFile);
}

void main()
{
	char originalFile[100];
	char newFile[100];

	printf("Please enter original file name and path: ");
	gets(originalFile);

	printf("\nPlease enter the new file name and path: ");
	gets(newFile);

	fileCopy(originalFile, newFile);
}
EDIT: Yes and thank you UMO for pointing out the fwrite function to me
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
copy, file, function

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 04:57 PM.