fork(1) download
  1. /* scanf example */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #pragma warning(disable:4996)
  6.  
  7.  
  8. int main()
  9. {
  10. char name;
  11. int age, i;
  12.  
  13. printf("Enter your first name letter: ");
  14. fflush(stdin);
  15. //scanf("%c", &name);
  16. name = getchar();
  17. // wyczysc bufor
  18. fflush(stdin);
  19. printf("Enter your age: ");
  20. scanf("%d", &age);
  21. //scanf_s("%d", &age);
  22. printf("Mr. %c , %d years old.\n", name, age);
  23. printf("Enter a hexadecimal number: ");
  24. scanf_s("%x", &i);
  25. printf("You have entered %#x (%d).\n", i, i);
  26. system("pause");
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0.01s 5552KB
stdin
c
12
10
compilation info
prog.c:5: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
prog.c: In function ‘main’:
prog.c:24:2: warning: implicit declaration of function ‘scanf_s’; did you mean ‘scanf’? [-Wimplicit-function-declaration]
  scanf_s("%x", &i);
  ^~~~~~~
  scanf
prog.c:20:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &age);
  ^~~~~~~~~~~~~~~~~
prog.c:26:2: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
  ^~~~~~~~~~~~~~~
/usr/bin/ld: /home/01n0xt/ccgZxdam.o: in function `main':
prog.c:(.text.startup+0xab): undefined reference to `scanf_s'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty