c++ visual-studio compiler-construction header

c++ - error fatal C1010-"stdafx.h" en Visual Studio ¿cómo se puede corregir esto?



visual-studio compiler-construction (3)

Recopilo el siguiente código pero obtengo un error de compilación en Visual Studio que no puedo entender.

#include <iostream> 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; }

El error dice:

"wordcount.cpp (57): error fatal C1010: final inesperado del archivo al buscar el encabezado precompilado. ¿Olvidó agregar ''#include" stdafx.h "'' a su fuente?

No creo que necesite un archivo de cabecera para ejecutar este código. Gracias por toda su ayuda de antemano.


Cree un nuevo " Proyecto vacío ", agregue su archivo Cpp al nuevo proyecto, elimine la línea que incluye stdafx.

Hecho.

El proyecto ya no necesita stdafx. Se agrega automáticamente cuando crea proyectos con plantillas instaladas.


La primera línea de cada archivo fuente de su proyecto debe ser la siguiente:

#include <stdafx.h>

Visite here para comprender los encabezados precompilados


Mira https://.com/a/4726838/2963099

Desactivar encabezados pre compilados:

Project Properties -> C++ -> Precompiled Headers

establecer Precompiled Header a "Not Using Precompiled Header" .