#include #include int main(int argc, char *argv[]){ int fd, i, fsize; char *first=(char *) malloc(1); char *last=(char *) malloc(1); if (argc != 2) { printf("pass two argumentsn"); exit (-1); } /* Open the file */ fd = open(argv[1], O_RDWR); if (fd == -1) { printf("error in file openingn"); exit (-1); }#ifdef PRINT printf("File Open Sucessn");#endif /* Find the file size */ fsize = lseek(fd, 0, SEEK_END);#ifdef PRINT printf("File Size = %dn", fsize);#endif /* Reverse the file */ for (i=0; i
#include<stdio.h>#include<unistd.h>#include<fcntl.h>#include<string.h>int main(){int fd=0,i=0,len=0;char buf[100];fd=open("file.txt",O_RDONLY);read(fd,buf,sizeof(buf));len=strlen(buf);for(i=len;i>=0;--i)printf("%c",buf[i]);printf(" ");}
Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.
Copyright ©2003-2009 CoolInterview.com, All Rights Reserved. Privacy Policy | Terms and Conditions Page URL: http://www.coolinterview.com/interview/5941/default.asp?cachecommand=bypass