반응형
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
written by jueon | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#define MAX_LENGTH 1000 | |
#define FILENAME "toGPT.txt" | |
int fileInsert(char* readfile, char* inputfilename) | |
{ | |
FILE * fp; | |
FILE * rf; | |
char str[MAX_LENGTH]; | |
rf = fopen(readfile, "r"); | |
fp = fopen(FILENAME, "w+"); | |
if(fp == NULL || rf == NULL) | |
{ | |
printf("There is a error at opening file"); | |
return 1; | |
} | |
int i = 0; | |
while(fgets(str, MAX_LENGTH, rf) != NULL) | |
{ | |
str[strlen(str) - 1] = '\0'; | |
if(i++ == 0) | |
{ | |
fprintf(fp,"echo \'%s\' > %s\n", str, inputfilename); | |
} | |
else | |
{ | |
fprintf(fp,"echo \'%s\' >> %s\n", str, inputfilename); | |
} | |
} | |
fclose(fp); | |
fclose(rf); | |
return 0; | |
} | |
int main(int argc, char** argv) | |
{ | |
if(argv[1] && argv[2]) | |
{ | |
fileInsert(argv[1], argv[2]); | |
} | |
else | |
{ | |
printf("Usage : ./code2GPT [Read file] [GPT file]\n\'Read file\' is a name of file to be read.\n\'GPT file\' is a name of file to be stored to ChatGPT.\n"); | |
} | |
return 0; | |
} |
반응형
'chatgpt > coding with ai' 카테고리의 다른 글
[c++] code2GPT (0) | 2023.02.07 |
---|---|
[bash shell] code2GPT (0) | 2023.02.07 |
[ruby] code2GPT (0) | 2023.02.07 |
[rust] code2GPT (0) | 2023.02.07 |
[python] code2GPT (0) | 2023.02.07 |