I would like to know how to do it after adding it () to the menu. Does anyone help?
#include <stdio.h>
#include <stdlib.h>
char descricao[40];
void adicionar(){
FILE * pFile;
printf("ESCREVA: ");
fgets (descricao,39,stdin);
pFile = fopen ("log.txt","a");
fputs (descricao,pFile);
fclose (pFile);
fflush(stdin);
getchar();
}
void menu(){
int opcao;
while (1){
puts("1... Adicionar artigo");
puts("2... Sair");
scanf("%d", &opcao);
switch (opcao){
case 1:
adicionar();
break;
case 2:
exit(0);
}
}
}
int main(){
menu();
}