My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
Advertisements
|
C Program File-copy program which copies text, .com and .exe files */
Posted Date: 08 Jun 2008 Resource Type: Articles/Knowledge Sharing Category: Computer & Technology
|
Posted By: Girish Patil Member Level: Diamond Rating: Points: 2
|
/* File-copy program which copies text, .com and .exe files */ #include "fcntl.h" #include "types.h" /* if present in sys directory use "c:tc\\include\\sys\\types.h" */ #include "stat.h" /* if present in sys directory use "c:\\tc\\include\\sys\\stat.h" */
main ( int argc, char *argv[ ] ) { char buffer[ 512 ], source [ 128 ], target [ 128 ] ; int inhandle, outhandle, bytes ;
printf ( "\nEnter source file name" ) ; gets ( source ) ;
inhandle = open ( source, O_RDONLY | O_BINARY ) ; if ( inhandle == -1 ) { puts ( "Cannot open file" ) ; exit( ) ; }
printf ( "\nEnter target file name" ) ; gets ( target ) ;
outhandle = open ( target, O_CREAT | O_BINARY | O_WRONLY, S_IWRITE ) ; if ( inhandle == -1 ) { puts ( "Cannot open file" ) ; close ( inhandle ) ; exit( ) ; }
while ( 1 ) { bytes = read ( inhandle, buffer, 512 ) ;
if ( bytes > 0 ) write ( outhandle, buffer, bytes ) ; else break ; }
close ( inhandle ) ; close ( outhandle ) ; }
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
|