Fatal error: stdafx.h file not found

I am new to C ++ programming and try to study on sites (learncpp.com), although I was already stuck in compiling my first program = (they use Visual Studio to program their code and because I use macbook, I just use vi and terminal (or should I use something else?)

Here's the helloworld.cpp program, written from a tutorial:

#include "stdafx.h"
#include <iostream>
{
     std::cout <<"Hello World!" <<std::end1;
     return 0;
}

when I compiled (gcc -Wall hello.cpp), I get an error:

helloworld.cpp:1:10: fatal error: 'stdafx.h' file not found

#include "stdafx.h"
         ^
1 error generated.

Can someone let me know how to fix this?

+4
source share
2 answers
  • stdafx.h - This is a precompiled header used by visual studio, you do not need it.
  • You seem to have missed the function int main()
  • std::endl not std::end1

- :

#include <iostream>
int main() {
     std::cout <<"Hello World!" <<std::endl;
     return 0;
}
+9

: a) stdafx.h ( ). b) "end1" "endl" ( "l" "1" ).

+1

Source: https://habr.com/ru/post/1533239/


All Articles