2015-01-02 2 views
0

나는 일기 예보를위한 C++ 프로그램을 작성하고 난 비주얼 스튜디오에 잘 작동 오류를누락 구분은 gcc가 오류를 일식 ++

/* 
Description Resource Path Location Type 
make: *** missing separator. Stop. subdir.mk /weather/Debug/src line 21 C/C++ Problem 

*/ 

코드를 다음 얻고 있지만 (ECLIPSE CDT에서 작동하지 않습니다 gcc 컴파일러).

/* output 


how many days:3 

enter data: 

enter day 1 

enater hightemp 45 

enter lowtemp 25 

enter rain 11 

enter snow 13 

enter day 2 

enater hightemp 34 

enter lowtemp 23 

enter rain 12 

enter snow 33 

enter day 3 

enater hightemp 54 

enter lowtemp 34 

enter rain 60 

enter snow 23 


entered data are 

1day 
1    45  25  11  13 

2day 
2    34  23  12  33 

3day 
3    54  34  60  23 


calculating avg 
avg for day 1 = 23.5 

calculating avg 
avg for day 2 = 25.5 

calculating avg 
avg for day 3 = 42.75 

*/ 
calculating avg 
avg for day 3 = 42.75 

*/ 

그러나 동일한 코드 일식에없는 일을하지 -이 :

여기
/* 
* aks.cpp 
* 
* Created on: 31-Dec-2014 
*  Author: student 
*/ 

#include<iostream> 
#include<stdio.h> 

using namespace std; 

class weather_report 
{ 
public: 

    int day, hightemp, lowtemp, amtrain, amtsnow; 



    weather_report() 
    { 
     day = 99; 
     hightemp = 999; 
     lowtemp = -999; 
     amtrain = 0; 
     amtsnow = 0; 
    } 

    void display() 
    { 
     cout << "\n " << day; 
     cout << "\t\t" << hightemp; 
     cout << "\t" << lowtemp; 
     cout << "\t" << amtrain; 
     cout << "\t" << amtsnow; 

    } 

    void Accept() 
    { 
     cout << "\n enter day "; 
     cin >> day; 
     cout << "\n enater hightemp "; 
     cin >> hightemp; 
     cout << "\n enter lowtemp "; 
     cin >> lowtemp; 
     cout << "\n enter rain "; 
     cin >> amtrain; 
     cout << "\n enter snow "; 
     cin >> amtsnow; 

    } 

    void average(int i) 
    { 
     i++; 
     int a; 
     float avg; 
     a = hightemp + lowtemp + amtrain + amtsnow; 
     avg = (float)a/4; 
     cout<<endl<< "avg for day " << i << " = " << avg << endl; 
    } 

}; 

int main() 
{ 
    int i, n; 
    weather_report w[5]; 
    cout << "\n how many days:"; 
    cin >> n; 
    cout << "\n enter data: "<<endl; 
    for (i = 0; i<n; i++) 
    { 
     w[i].Accept(); 
    } 

    cout <<endl<<endl<< "entered data are"; 
    for (i = 0; i<n; i++) 
    { 
     cout<<endl<< " " << endl << i + 1 << "day"; 
     w[i].display(); 
    } 

    cout <<endl<< endl; 
    for (i = 0; i<n; i++) 
    { 
     cout << endl<<"calculating avg "; 
     w[i].average(i); 

    } 

    return 0; 

} 

비주얼 스튜디오의 출력은 다음과 같습니다 (http://prntscr.com/5nnpap)

다음

이 코드는 다음과 같습니다

은 이미지입니다 (gcc 컴파일러)

+1

어디 선 21입니까? –

+2

_missing separator_는 소스 코드가 아닌'make '빌드 도구의 오류입니다. 그래서 문제는 'subdir.mk' 안에 있으며 오류 보고서에서 지적하고 있습니다. 메이크 파일이 이클립스에 의해 자동으로 생성되는지, 아니면 다른 종류의 문제인지는 잘 모르겠습니다. – Jack

+1

21 행의 공백이 아닌 탭을 사용하십시오. –

답변

0

나는 그것이 Eclipse (3.8)에서 작동하지 않는 이유를 모르지만 비주얼 스튜디오. 그러나 이클립스를 4.4v로, GCC를 4.9로 업데이트했다. 이제는 오류없이 코드가 제대로 작동한다.