I am very new to c++ and am doing a tutorial. I have copied the tutorial exactly but on compiling get this error:
'String file not found'
for the line #include <string>;
Could someone tell me how to amend this?
Ok, so I changed the name of my file from .C to .cpp and this particular issue seems to have gone.
You seem to have found a solution, I'm adding this to clarify why this is happening. Some compilers integrated with IDEs treat .c
files as C source code an .cpp
(or .cc
, .c++
, etc.) as C++ code. As you compile a .c
file, C++ support isn't included and a C compiler is used instead of a C++ one. And C doesn't have <string>
(although it does have <string.h>
, but that contains entirely different stuff).
It looks like your compiler isn't correctly or fully installed. The compiler should be able to find its own headers without further effort on your part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With