fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <fcntl.h>
  5. #include <unistd.h>
  6.  
  7. int main()
  8. {
  9. int fp;
  10. int i;
  11. int len;
  12. char buf[300];
  13.  
  14. memset(buf, 0x00, 300);
  15.  
  16. if((fp=open("texti",O_RDWR)) == 0)
  17. {
  18. perror("open: ");
  19. exit(0);
  20. }
  21. write((int)fp,"Have a goodtime.", 16);
  22. close((int)fp);
  23.  
  24.  
  25. //https://l...content-available-to-author-only...e.net/man/3/open
  26. //int open(const char *path, int oflag, ... );
  27. if((fp=open("texti",O_RDWR)) == 0)
  28. {
  29. perror("open: ");
  30. exit(0);
  31. }
  32.  
  33. //fgets(buf,16,(FILE*)fp);
  34. read(fp, buf, 16);
  35. printf("%s\n", buf);
  36.  
  37. /*
  38. //http://w...content-available-to-author-only...s.com/reference/cstdio/fgets/
  39. //char * fgets ( char * str, int num, FILE * stream );
  40.   while(fgets(buf,sizeof(buf),(FILE*)fp)!= NULL)
  41.   {
  42.   len = strlen(buf);
  43.   for(i=0; i<len; i++)
  44.   {
  45.   if((buf[i] >= 'a') && (buf[i] <= 'z'))
  46.   {
  47.   buf[i] -= ('a'-'A');
  48.   }
  49.   }
  50.  
  51.   }
  52. */
  53. //https://l...content-available-to-author-only...e.net/man/3/write
  54. //ssize_t write(int fildes, const void *buf, size_t nbyte);
  55. write((int)fp,buf,sizeof(buf));
  56.  
  57. //https://l...content-available-to-author-only...e.net/man/3/close
  58. //int close(int fildes);
  59. close((int)fp);
  60.  
  61. return 0;
  62. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout