Skip to content

Instantly share code, notes, and snippets.

@skymansandy
Created November 3, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skymansandy/98ad1b4307774b0be2474f96f94db8d9 to your computer and use it in GitHub Desktop.
Save skymansandy/98ad1b4307774b0be2474f96f94db8d9 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
char buff1[ ]="abcdefghijklmnop ";
char buff2[ ]="ABCDEFGHIJKLMNOP ";
int fd;
fd=open("new.dat",O_WRONLY|O_CREAT,0777);
write(fd,&buff1,16);
lseek(fd,48,SEEK_SET);
write(fd,&buff2,16);
close(fd);
printf("The contents of the file are:\n");
system("od -c new.dat");
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment