Guest User

Untitled

a guest
Nov 2nd, 2026
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. /*
  4.     Simple program to initiate a simple C code.
  5.  
  6.     Pretty convenient...no?
  7. */
  8.  
  9. char initial_code[] = "#include <stdio.h>\n\n\nint main(int argc, char* argv[]){\n\n\n\treturn 0;\n}\0";
  10.  
  11. int main(int argc, char* argv[]){
  12.  
  13.     if(argc > 2)
  14.         printf("Too much arguments.\n");
  15.     else if(argc < 2)
  16.         printf("File name required\n");
  17.     else{
  18.         FILE *file;
  19.         if((file = fopen(argv[1], "w")) == NULL){
  20.             printf("Error writing to file");
  21.             return 1;
  22.         }
  23.         else{
  24.             int c,i;
  25.             i = 0;
  26.             while((c = initial_code[i++]) != '\0')
  27.                 putc(c, file);
  28.             fclose(file);
  29.         }
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment