C言語初心者です。今cの問題を解いて練習しています。次のプログラムを実行したんですがエラーがでてしまいました。しかし、答えを見ても変数が違うだけで見たことのないエラーが出てきてしまいます。しかも、そのエラーが意味がわかりません。どなたか教えていただきませんでしょうか?;
//プログラム//
1 #include<stdio.h>
2
3 int sum(int);
4
5 int main(void)
6 {
7
8 int n;
9
10
11 int ans;
12 printf("整数をにゅうりょくして");
13
14
15 scanf("%d",&n); ←問題の部分です;
ans=sum(n);
printf("合計は%d\n",ans);
}
int sum(int x)
{
int hako=0;
int i;
for(i=0;i<x;i++){
hako+=i;
}
return hako;
}
//エラー一覧//
------ ビルド開始: プロジェクト: hello, 構成: Debug Win32 ------
コンパイルしています...
hello.cpp
c:\users\masaki\documents\visual studio 2008\projects\hello\hello\hello.cpp(15) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : 'scanf' の宣言を確認してください。
c:\users\masaki\documents\visual studio 2008\projects\hello\hello\hello.cpp(15) : error C3872: '0x3000': この文字を識別子で使用することはできません
c:\users\masaki\documents\visual studio 2008\projects\hello\hello\hello.cpp(15) : error C3872: '0x3000': この文字を識別子で使用することはできません
c:\users\masaki\documents\visual studio 2008\projects\hello\hello\hello.cpp(15) : error C3872: '0x3000': この文字を識別子で使用することはできません
c:\users\masaki\documents\visual studio 2008\projects\hello\hello\hello.cpp(16) : error C2065: ' ' : 定義されていない識別子です。
c:\users\masaki\documents\visual studio 2008\projects\hello\hello\hello.cpp(16) : error C2146: 構文エラー : ';' が、識別子 'ans' の前に必要です。
ビルドログは "file://c:\Users\masaki\Documents\Visual Studio 2008\Projects\hello\hello\Debug\BuildLog.htm" に保存されました。
hello - エラー 5、警告 1
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========