#include <stdio.h>
#include <stdlib.h>
int main()
{
int x = 1;
printf("please make a selection with your keyboard\n");
sleep(1);
printf("1.\n");
char input;
scanf ("%c", &input);
switch (input) {
case '1':
x=x+1;
printf(x);
}
return(0);
}
변수를 자체적으로 추가 한 다음 해당 변수를 출력하려고하지만 코드가 작동하지 않는 것 같습니다.printf 변수 C
printf("%d\n", x);
이 reference page이 printf
및 관련 기능의 사용 방법에 대한 자세한 설명을 제공합니다
내 출력 오류가
newcode1.c: In function ‘main’:
newcode1.c:20:2: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast [enabled by default]
In file included from newcode1.c:1:0:
/usr/include/stdio.h:362:12: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
newcode1.c:20:2: warning: format not a string literal and no format arguments [-Wformat-security]
처리 나에게 정말 유용했다, 당신은 변수를 인쇄되지 않는 경우, 당신은 일부 변수의 [현재] * 값 *을 출력합니다. –
또한,'scanf '전에'input'을 초기화하고'scanf' 결과를 테스트하는 것이 더 좋습니다 –