scanf
ожидает указатель на массив символов, вы передаете ему указатель на указатель на массив символов
scanf("%s",&firstchoice);
Приведенная выше строка должна быть
scanf("%s",firstchoice);
или
scanf("%s",&firstchoice[0]);
Кроме того, вы не можете просто сравнить массив символов со строковым литералом, используя ==
, вы должны использовать strcmp
.
Компиляция вашего кода вызвала следующие предупреждения. Я предлагаю вам начать обращать на них внимание; увеличьте уровень предупреждений вашего компилятора, если вы их не видите.
prog.c: In function ‘main’:
prog.c:22: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[200]’
prog.c:23: warning: comparison with string literal results in unspecified behavior
prog.c:23: warning: comparison with string literal results in unspecified behavior
prog.c:26: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[200]’
prog.c:53: warning: comparison with string literal results in unspecified behavior
prog.c:53: warning: comparison with string literal results in unspecified behavior
prog.c:57: warning: comparison with string literal results in unspecified behavior
prog.c:57: warning: comparison with string literal results in unspecified behavior
prog.c:61: warning: comparison with string literal results in unspecified behavior
prog.c:61: warning: comparison with string literal results in unspecified behavior
prog.c:83: warning: comparison with string literal results in unspecified behavior
prog.c:83: warning: comparison with string literal results in unspecified behavior
prog.c:22: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:26: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:49: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:64: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:81: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:49: warning: ‘textwrite’ may be used uninitialized in this function
prog.c:64: warning: ‘filenameopen’ may be used uninitialized in this function
prog.c:81: warning: ‘textopen’ may be used uninitialized in this function