Enter your email address & Win:

System Software Lab Programs ( UNIX Programs ) – 2b

// March 6th, 2009 // Engineering, Unix and System Software Lab // Written by sandeephegde

-->

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

2. b) C program to create a file with 16 bytes of arbitrary data from the beginning and another 16 bytes of arbitrary data from an offset of 48. Display the file contents to demonstrate how the hole in file is handled.

……………………………………………………………………………………………………………………………

#include<stdio.h>

#include<unistd.h>

main()

{

FILE *fp;

int i,j;

char ch;

fp=fopen(“text.txt”,”w”);

ch=’a';

for(i=o;i<16;i++)

{

fwrite(&ch,1,1,fp);

ch++;

}

fseek(fp,48L,1);

ch=’A';

for(j=0;j<16;j++)

{

fwrite(&ch,1,1,fp);

ch++;

}

fclose(fp);

fp=fopen(“text.text”,’r”);

while((fread(&ch,1,1,fp))!=0)

print(“%c”,ch);

fclose(fp);

}

[Request : If you are going to post this program on any other website please link back to original post ]



If you enjoyed this post, make sure you subscribe to my RSS feed!

Related posts:

  1. System Software Lab Programs ( UNIX Programs ) – 3b
  2. System Software Lab Programs ( Lex and Yaac Programs )exa
  3. System Software Lab Programs ( UNIX Programs ) – 3a
  4. System Software Lab Programs ( UNIX Programs ) – 2a
  5. System Software Lab Programs ( UNIX Programs ) – 1B
blog comments powered by Disqus
Get Adobe Flash playerPlugin by wpburn.com wordpress themes