私はTurbo C++を使用しており、私自身でプログラムを実行しようとしています。私はたくさんの質問をしていました。私はサイトを見て、このエラーを除いてすべてを解決しました。プログラムが実行され、出力が表示されると、プログラムは終了しません。 Ctrl + Breakは機能しません。私はそれを閉じてもう一度実行できます。誰でも助けてくれますか?出力後にプログラムが終了しない
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
int n;
void disp()
{
cout<<"\tPERIODIC TABLE OF THE s-BLOCK ELEMNTS\n"<<endl;
cout<<"\t1\n\tH\n"<<endl;
cout<<"\t3\t4\n\tLi\tBe\n"<<endl;
cout<<"\t11\t12\n\tNa\tMg\n"<<endl;
cout<<"\t19\t20\n\tK\tCa\n"<<endl;
cout<<"\t37\t38\n\tRb\tSr\n"<<endl;
cout<<"\t55\t56\n\tCs\tBa\n"<<endl;
cout<<"\t87\t88\n\tFr\tRa\n"<<endl;
cout<<"Enter the Atmic number of the element you want to know more about \n";
cin>>::n;
}
void open()
{
ifstream elements;
char x[200];
switch(::n)
case 1:elements.open("Hydrogen.txt");
while(elements)
{
elements.getline(x, 200, '\n');
cout>>x;
}
}
void main()
{
clrscr();
disp();
open();
getch();
}
コード内に 'cout << x'という行はありません。また、 'void main'は間違っています。 'main'は' int'を返さなければなりません。 – melpomene
'cout'は出力ストリームです。あなたはそれを読み込もうとしています。あなたは '' 'を意味しましたか? –
* Turbo C++ *を使用します - なぜですか?そのコンパイラは25歳以上であり、ANSI標準ではありません。 [The C++ info](https://stackoverflow.com/tags/c%2b%2b/info)とTurbo C++については何かをお読みください。 g ++、CLang、Visual C++のコミュニティ版など、はるかに優れた最新のオプションがあります。 – PaulMcKenzie