strings not working

Hello, as you may know already I am new to the C++ environment. Recently I have been trying to wright a program using strings (shown below) however, it says that "string was undeclared. I am using xcode on OSX 10.6 please help thanks in advance!


1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <stdlib.h>
#include <string>

int main (int argc, char * const argv[]) {
	string mystring;
	mystring = "abcdef";
	cout << mystring[2];
    return 0;
}
Unless you include the std namespace then the name of the datatype is "std::string"
either do

using namespace std; at the beginning.

or use std::string in the code.
just fixed it thanks for the help!
Topic archived. No new replies allowed.