Code Blocks IDE variably recognising #include <string>

code in question folllows, error message is that string was not declared in this scope.
If i declare a string test, it comes back nd tells me that string dos not defin a type.

However, the same code, on the same mavhine, in a different prog works. so why the bliminy flipping heck des it not recognise the string library?

Heeeeeeeeeelp! :)

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <time.h>


int iLives=3, iCount=0, iPosition=0, iChecksum=0;

int GetIntVal(string strConvert)
{
int intReturn;
intReturn = atoi(strConvert.c_str());
return(intReturn);
}
The proper name of 'string' is std::string. If you're not putting it in the global namespace, the compiler will assume you're referring to some other string. If no other string is defined, the compiler complains.
um, what?

sorry, not following.

however i found that also just including "using namespace std;" solved the issue

thanks for the answer anyway
Last edited on
If you didn't know what helios is talking about, you should look up namespaces.
You shouldn't just add lines to your code when you have no idea what they're actually doing.
closed account (jwC5fSEw)
You shouldn't just add lines to your code when you have no idea what they're actually doing.


++

Do a little research. Namespaces aren't too hard to understand.
Topic archived. No new replies allowed.