Advertisement
montimaj

AS1

Aug 14th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<sys/file.h>
  2. #include<sys/types.h>
  3. #include<sys/stat.h>
  4. #include<unistd.h>
  5. #include<stdio.h>
  6. int main()
  7. {
  8.   char t[100],f[30];
  9.   int i=0, fd;
  10.   printf("Enter a text:\n");
  11.   while((t[i++]=getchar())!='\n');
  12.   t[--i]='\0';
  13.   printf("\nEnter new file name: ");
  14.   scanf("%s",f);
  15.   fd=creat(f,S_IWUSR);
  16.   if(fd==-1)
  17.     return 1;
  18.   write(fd,t,i);
  19.   close(fd);
  20.   return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement