Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- Simple program to initiate a simple C code.
- Pretty convenient...no?
- */
- char initial_code[] = "#include <stdio.h>\n\n\nint main(int argc, char* argv[]){\n\n\n\treturn 0;\n}\0";
- int main(int argc, char* argv[]){
- if(argc > 2)
- printf("Too much arguments.\n");
- else if(argc < 2)
- printf("File name required\n");
- else{
- FILE *file;
- if((file = fopen(argv[1], "w")) == NULL){
- printf("Error writing to file");
- return 1;
- }
- else{
- int c,i;
- i = 0;
- while((c = initial_code[i++]) != '\0')
- putc(c, file);
- fclose(file);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment