致命错误C1010 - 在Visual Studio中的"stdafx.h",如何修正?
致命错误C1010 - 在Visual Studio中的"stdafx.h",如何修正?
我编译了下面的代码,但在Visual Studio中出现了一个我无法理解的编译错误。
#include using namespace std; int main() { int matchCount, findResult; long childPID; string userInput = "blank"; // string to be searched through string longString = "The PPSh-41 is a Soviet submachine gun designed by Georgi Shpagin as an inexpensive, simplified alternative to the PPD-40."; while (userInput.compare("!wq")); { // reset variables for reuse matchCount = 0; findResult = -1; cout << "Please enter a word/s to search for (!wq to exit): "; // prompts user for string to search for cin >> userInput; // takes user input if (userInput.compare("!wq")) // checks user input to see if they still wish to search for a string { childPID = fork(); if (childPID == 0) { while (findResult < longString.length) { findResult = longString.find(userInput, findResult + 1, userInput.length); if (findResult < longString.length) matchCount++; } cout << "There are " << matchCount << " instances of " << userInput << " in longString." << endl; } else cout << "childPID != 0" << endl; } else cout << "User has chosen to exit. Exiting." << endl; } return 0; }
错误提示如下:
\"wordcount.cpp(57) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add \'#include \"stdafx.h\"\' to your source?\"
我认为我不需要头文件来运行这段代码。提前感谢您的所有帮助。
admin 更改状态以发布 2023年5月21日