▼スレッド
│
└◇1467:コンパイルのエラーが出ます。(初心者) [naga] 09/12 13:26
└◇1468:Re:コンパイルのエラーが出ます。(初心者) [MSだす。] 09/12
└◇1469:Re[2]:コンパイルのエラーが出ます。(初心者) [naga] 09/12 <
スレッド一覧
プログラム初心者です。
本「初めてのC++」で独学勉強中です。
そこで下記のサンプルプログラム(少しだけ変更)を
コンパイルすると
[hate@number_hex]$ g++ -g -O0 p110_wari_.c
p110_wari_.c:23: parse error before character 0245
とエラーがでます。
いろいろ試しましたが・・
エラーの意味がわからずに困っています。
何方か教えていただきたく思います。
よろしくお願いします。
プログラムは下記のとおりです。
#include <iostream.h>
int main ()
{
int wari1, wari2 ;
cout << "warizan" << endl;
cout << "input_a" << endl;
cin >> wari1 ;
cout << "input_b" << endl;
cin >> wari2 ;
if (! wari2){
cout << "0 ha NG " << endl;
return 1 ;
}
cout << wari1 << "/" << wari2 << "="
<< wari1 / wari2 << "... "
<< wari1 % wari2 << endl;
return 0 ;
}
そのプログラムをコピペしてコンパイルしてみましたが、スレッド一覧
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
from p110_wari_.c:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
の警告が出る以外は問題なくコンパイルできましたよ?
ファイル中にゴミが入っているのかもしれません。
もう一度別ファイルに書きなおしてコンパイルしてみてはどうでしょう。
>p110_wari_.c:23: parse error before character 0245
23行目でエラーになっていますが、ファイルの末尾に
なにかゴミが入っているのではないかと想像しますが。
スレッド一覧
23行目以降見た目に何も無かったのですが、
22行目から削除して
再度、書き直したらコンパイルできました。
ありがとうございます。
・・悩んでいましたのでたすかりました。