C ++ - error with <string>

I am very new to C ++ and am doing a tutorial. I copied the tutorial for sure, but when compiling, get this error:

'String file not found'

for line #include <string>;

Can someone tell me how to change this?

+6
source share
4 answers

Ok, so I changed my file name from .C to .cpp, and this particular problem seems to be gone.

You seem to have found a solution, I am adding this to clarify why this is happening. Some compilers integrated with the IDE treat .c files as C a .cpp source code (or .cc , .c++ , etc.) as C ++ code. When you compile a .c file, C ++ support is not enabled, and the C compiler is used instead of C ++. And C does not have <string> (although it has <string.h> , but it contains completely different things).

+4
source

It looks like your compiler is installed incorrectly. The compiler should be able to find its own headers without any extra effort on your part.

+3
source

Ok, so I changed my file name from .C to .cpp, and this particular problem seems to be gone. However, now I get 3 errors Apple Mach-o Linker (Id) (?)

Since this is different from the original questions, I close it and open a new one

Thanks for the help!

+1
source

check location c:/...../include

If the string file exists, you must reinstall the compiler

-1
source

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


All Articles