"ramesh" <ra*******@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
can any one help me to solve this one we need to write a c program,
Consider a file of size 5000 bytes. Open the file and read to a buffer
of size buf[1000];
We have to read 1000 bytes only from the file at a time and after
displaying the file we have to lseek 500 bytes back in the file
And read file from 500 to 1000. we have to read this type upto end of
file .
suggestion: read only 500 bytes at a time. It will eliminate an lseek.
?type? buf[1000];
?type? buf2[500];
fread() 500 using into buf2[] /* buf2 has 0-500 */
memcpy() buf2[] into buf[0] /* buf has 0-500 */
fread() 500 using into buf2[] /* buf2 has 500-100 */
memcpy() buf2[] into buf[500] /* buf has 0-500 and 500-1000 */
display 1000 bytes of buf[];
process 500 bytes of buf2[]; /* buf2 still has bytes 500-1000 */
loop & process 500 bytes of buf2[]; /* bytes 1000+, 500 at a time */
Rod Pemberton