If for some reasons you do not want to use "Precompiled Headers" (or do no know how), then remove the '#include <stdafx.h>' line.
Erroe code E1696 in line #include <stdafx.h>
Im building a Arduino project. Only in the last few days have I started registering C ++. I'm trying to create software that reads a line from a file that will send through serial port or bluetooth. This is what I was able to collect from the internet.
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <stdafx.h>
//using namespace System;
//using namespace System::IO::Ports;
int main()
{
//SerialPort port("COM9", 9600);
//port.Open();
std::ifstream file("scan.txt");
std::vector<std::string>names;
std::string input;
while (file >> input)
{
names.push_back(input);
}
for (std::string name : names)
{
std::cout << name << std::endl;
//port.Write(name);
}
return 0;
}
The lines that are notice causing me problems I think it has to do with the line #include <stdafx.h>. When I try to run the code I get the error E1696 "cannot open source file "stdafx.h""
I tried all of these possibilities
Im using Visual Studio 2019 onn win 10 machine.
Developer technologies | C++
2 answers
Sort by: Most helpful
-
-
Guido Franzke 2,191 Reputation points2021-04-15T10:12:43.457+00:00 Hello,
as already said, the file stdafx.h is used for precompiled headers. In most projects of Visual Studio it is standard that the file is created automatically.
It looks like you created your project in another way. Now you want to use a source file that includes stdax.h.
The easiest way to solve your problem is: create an empty text file in your project directory and rename it to "stdafx.h".
Regards, Guido