Windows에서 Visual Studio에 프로그램을 작성했지만 프로그램이 올바르게 컴파일되지만 콘솔에 원하는 출력이 표시되지 않습니다. 그러나 Linux에서 Gedit으로 프로그램을 컴파일하고 실행하면 올바른 출력이 표시되고 모든 것이 작동합니다. 왜 이런거야? 코드는 다음과 같습니다.C++ 코드는 Gedit에서 작동하지만 VS에서는 작동하지 않습니다.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string input;
cout << "College Admission Generator\n\n";
cout << "To begin, enter the location of the input file (e.g. C:\\yourfile.txt):\n";
cin >> input;
ifstream in(input.c_str());
if (!in)
{
cout << "Specified file not found. Exiting... \n\n";
return 1;
}
char school, alumni;
double GPA, mathSAT, verbalSAT;
int liberalArtsSchoolSeats = 5, musicSchoolSeats = 3, i = 0;
while (in >> school >> GPA >> mathSAT >> verbalSAT >> alumni)
{
i++;
cout << "Applicant #: " << i << endl;
cout << "School = " << school;
cout << "\tGPA = " << GPA;
cout << "\tMath = " << mathSAT;
cout << "\tVerbal = " << verbalSAT;
cout << "\tAlumnus = " << alumni << endl;
if (school == 'L')
{
cout << "Applying to Liberal Arts\n";
if (liberalArtsSchoolSeats > 0)
{
if (alumni == 'Y')
{
if (GPA < 3.0)
{
cout << "Rejected - High school Grade is too low\n\n";
}
else if (mathSAT + verbalSAT < 1000)
{
cout << "Rejected - SAT is too low\n\n";
}
else
{
cout << "Accepted to Liberal Arts!!\n\n";
liberalArtsSchoolSeats--;
}
}
else
{
if (GPA < 3.5)
{
cout << "Rejected - High school Grade is too low\n\n";
}
else if (mathSAT + verbalSAT < 1200)
{
cout << "Rejected - SAT is too low\n\n";
}
else
{
cout << "Accepted to Liberal Arts\n\n";
liberalArtsSchoolSeats--;
}
}
}
else
{
cout << "Rejected - All the seats are full \n";
}
}
else
{
cout << "Applying to Music\n";
if (musicSchoolSeats>0)
{
if (mathSAT + verbalSAT < 500)
{
cout << "Rejected - SAT is too low\n\n";
}
else
{
cout << "Accepted to Music\n\n";
musicSchoolSeats--;
}
}
else
{
cout << "Rejected - All the seats are full\n";
}
}
cout << "*******************************\n";
}
return 0;
}
감사합니다.
EDIT : 보풀이 제거되었습니다.
명확히하기 위해 프로그램은 VS에서 컴파일됩니다. 파일을 열지 만 파일에서 정보를 반향하지 않고 "종료하려면 아무 키나 누르십시오." 메시지.
어떤 오류 메시지가 나타 났습니까? 컴파일 되었습니까? 어쩌면'#include'을 포함시켜야할까요? –
wally
정확하게 작동하지 않는 경우, 정확히 작동하지 않는 경우, 편집기, 어쩌면 잘못된 파일, 컴파일러 등과 관련이 없습니다. –