I know that scanf before fgets its interfering my program but I dont know how to solve it. I tried thing like 'scanf("%d , &op)'(add space), 'scanf("%d\n", &op)' and getchar() but it doesnt working anyway. When I used getchar() I could write the sentence later, but it just reads the first character. Does anyone know how can I solve it?
'''
int main(){
int op=0;
printf("MENU\n");
printf("1. Code\n2. Decode\n\n");
scanf("%d", &op);
getchar()
switch(op){
case 1:{
char line[TAM];
int i,tam=0;
printf("Write somethingg: ");
fgets(line,TAM, stdin);
for (i=0;line[i];i++){
tam++;
}if (tam>TAM){
printf ("ERROR");
main();
}else{
process(line);
}
break;
}
'''