SHARE
TWEET

Untitled

a guest Feb 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FILE *tmp_copy = tmpfile();
  2. file = fopen ( argv[2], "rw" );    
  3. if ((file != NULL )) {
  4.     char line [ 128 ]; /* or other suitable maximum line size */
  5.     while( ( fgets ( line, sizeof line, file ) != NULL ))  {
  6.        fputs(line, tmp_copy);
  7.     }
  8.     fclose ( file );
  9.  
  10.         rewind(tmp);
  11.         char *p;
  12.       /* Reopen file now with write permissions */
  13.         fopen(argv[2], "w");
  14.         while (( p = fgets(line, 1024, tmp))!=NULL) {
  15.             //line[strlen(line)-1] = ''; /* Clear away newline */
  16.             //sprintf(line, "%s %sn", line, more);
  17.             strcpy(line,"true");
  18.             //fputs(line, file);
  19.         }
  20. fclose(file);
  21. fclose(tmp);
  22.             }
  23.  
  24. }
  25.    
  26. original_file = fopen(original_file_name, "r");
  27. temporary_file_name = tmpnam("dummy");
  28. temporary_file = fopen(temporary_file_name, "w");
  29.  
  30. while (fgets(line, original_file))
  31. {
  32.     remove_trailing_newline(line);
  33.     strcat(line, " TRUEn");
  34.     fputs(line, temporary_file);
  35. }
  36.  
  37. fclose(temporary_file);
  38. fclose(original_file);
  39.  
  40. rename(temporary_file_name, original_file_name);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top