c - Getting an "implicit declaration of function" error in Code Blocks -
i still quite new c, , keep getting error in code blocks stops me running programs. error "implicit declaration of functions printf_s() , scanf_s(). here code:
#define __stdc_want_lib_ext1__ 1 #include <stdio.h> int main(void) { int age = 0; char name[20]; printf_s("enter age: "); scanf_s("%d", &age); print_s("enter name: "); scanf_s("%s", name, sizeof(name)); printf_s("your name %s , %d years old.\n", name, age); return 0; }
printf_s
, scanf_s
available if __stdc_lib_ext1__
defined library implementation. added since c11 standard.
first have check __stdc_lib_ext1__
defined or not, should use printf_s
or scanf_s
.
#define __stdc_want_lib_ext1__ 1 #include <stdio.h> int main(void) { int age = 0; char name[20]; #ifdef __stdc_lib_ext1__ printf_s("enter age: "); scanf_s("%d", &age); print_s("enter name: "); scanf_s("%s", name, sizeof(name)); printf_s("your name %s , %d years old.\n", name, age); #else printf("enter age: "); scanf("%d", &age); print("enter name: "); scanf("%19s", name); printf("your name %s , %d years old.\n", name, age); #endif return 0; }
Comments
Post a Comment