Can I use scanf_s in CLion?

已回答

 I am trying to learn the C programming language and some code that I found used scanf_s,but it doesn't compile with CLion.

The code below compiles fine in VS2015, but doesn't link in CLion on OS X

#include <stdio.h>

int main() {
printf("Hello, World!\n");
int myAge = 0;
printf("How old are you?\n");
scanf_s("%d", &myAge);
printf("You said you are %d years old.\n", myAge);
return 0;
}
0

scanf_s is a Microsoft-specific function, so it is currently unavailable in CLion since it supports only MinGW/cygwin toolchains. We plan to support MSVC toolchain in the next release. Please use scanf instead.

0

Thank you Anna!

Glad to hear that MSVC support is coming.

I thought that since it was listed on cppreference.com it was part of the C11 standard.

I'll look forward to the next release and replace scanf_s with scanf.

0

请先登录再写评论。