c语言中错误c1010,c++ 致命错误C1010 – “stdafx.h”在Visual Studio中如何纠正?

我编译下面的代码,但是我在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):致命错误C1010:寻找预编译头文件时意外的文件结尾您是否忘记将”#include“stdafx.h”’添加到源文件?

我不相信我需要一个头文件来运行这个代码。谢谢你提前的帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值