実現したいこと
scanf_s関数を使ってのキーボードからの入力
前提
C言語の入門書を読みながら学習しています。
発生している問題・エラーメッセージ
scanf_s関数を使うとコンパイル時にエラーになります。Macでvisual studio code を使っていますが、chromeのwebブラウザ上でhttps://paiza.io/jaやhttps://9cguide.appspot.com/web_picoc_em.htmlに同じコードを入力してもエラーになります。エラーメッセージはtests.c:7:5: error: call to undeclared function 'scanf_s'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
scanf_s("%d",&a);
^
tests.c:7:5: note: did you mean 'scanf'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:174:6: note: 'scanf' declared here
int scanf(const char * __restrict, ...) __scanflike(1, 2);
です。
該当のソースコード
#include <stdio.h>
int main(void){
int a=0;
scanf_s(“%d”,&a);
prints(“あなたは%dと入力しましたね”,a);
return 0;
}
試したこと
#define _CRT_SECURE_NO_WARNINGSを
#include <stdio.h>の前に置く
補足情報(FW/ツールのバージョンなど)
質問の仕方はこれで良かったでしょうか。申し訳ありませんが、教えていただけると嬉しいです。

回答3件
あなたの回答
tips
プレビュー