Unknow type name 'string'

+1 Matej Budin · January 6, 2015
Hi all,

I'm totally new in the C++ world. I've been experiencing the following issue. Though I included <string>, my pc cannot recognize any string variable. It complains "Unknow type name 'string' ". Does anybody have any idea?

Thanks in advance for your help.


Post a Reply


Oldest  Newest  Rating
0 Alf Nohr · January 6, 2015
As the  string is in the std namespace, should you either use
using namespace std;

or  write each of your strings like this
std::string myString;

Example with "using namespace std;":

#include <string>

using namespace std;

int main(){

string myString = "theString";

return 0;


Example without "using namespace std;"

#include <string>

int main(){

std::string myString = "theString";

return 0;


This is probably the reason, if you still can't fix it, please post your code :)
+1 Matej Budin · January 7, 2015
Thanks a lot for your help!!!
Actually it worked!!

+1 Alf Nohr · January 7, 2015
You're Welcome :)
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator