-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcprogram.c
46 lines (40 loc) · 941 Bytes
/
cprogram.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
void call_python_script()
{
int ret = system("pythonscript.py");
if (ret == -1) {
perror("Error calling Python script");
exit(1);
}
}
void file_printer(char filename[])
{
FILE *fp;
fp=fopen(filename,"r");
if(fp==NULL)
{
perror("Error while opening fiile");
exit(0);
}
char ch;
while((ch=fgetc(fp))!=EOF) putchar(ch);
fclose(fp);
}
int main() {
FILE *file;
char string[100];
printf("Enter the name of the recipe you want :");
scanf("%s",string);
file = fopen("prompt.txt", "w");
if (file == NULL) {
printf("Error opening file!\n");
return 1;
}
fprintf(file, "%s\n", string);
fclose(file);
printf("String written to the file successfully.\n");
call_python_script();
file_printer("result.txt");
return 0;
}