#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);
}
Kendisine bir değişken oluşturmayı deniyorum ve sonra bu değişkeni yazdıracağım ancak kodumun çalışmasını sağlayamıyorum.printf değişkeni C
printf("%d\n", x);
Bu reference pageprintf
ve ilgili işlevler nasıl kullanılacağı hakkında ayrıntılı bilgi verir:
benim çıkış hatası
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]
uğraşan benim için gerçekten yararlı oldu, bir değişken basılmıyor, öyle Bazı değişkenlerin [mevcut] * değerini * yazdırmak. –
Ayrıca, "scanf" den önce 'input'un başlatılması daha iyidir ve 'scanf' –