0
我剛開始用C++基於Eclipse(霓虹燈3)編程舊的代碼,但我已經遇到了一個奇怪的問題:Eclipse中始終構建即使存在更新的代碼
我寫了一些簡單的代碼,試圖建立它,遇到錯誤並且改變了代碼中的某些內容。現在我想重建它,但它仍然顯示相同的錯誤,並且在控制檯中,它只打印舊代碼。我試圖使用乾淨,但沒有幫助。
我的代碼:
#include <iostream>
#include <string>
using namespace std;
int main() {
string input;
cout << " Bitte geben sie eine Buchstabenfolge ein. " << endl;
getline(cin,input);
//char first_letter = input[0];
//cout << first_letter;
return 0;
}
(我知道,這個代碼是可能的垃圾,我只是嘗試了一下)
控制檯輸出:
16:20:21 **** Incremental Build of configuration Debug for project ue3.2 ****
make all
Building file: ../src/ue3.2.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ue3.2.d" -MT"src/ue3.2.o" -o "src/ue3.2.o" "../src/ue3.2.cpp"
../src/ue3.2.cpp: In function ‘int main()’:
../src/ue3.2.cpp:17:22: error: cannot convert ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘char’ in initialization
char first_letter = input ;
^
src/subdir.mk:18: recipe for target 'src/ue3.2.o' failed
make: *** [src/ue3.2.o] Error 1
16:20:21 Build Finished (took 129ms)
至少你應該提供代碼和你得到的錯誤信息 –
它看起來好像在生成運行之前沒有保存文件?你能否確認這個文件確實被保存了(根據Eclipse,文件名前面沒有*),並且如果你在另一個編輯器中打開該文件,內容在那裏?如果內容在那裏,那麼g ++不會編譯您認爲它的文件,因此請檢查路徑。 –