Link to home
Start Free TrialLog in
Avatar of nick81
nick81

asked on

String (newb)

Hi all,

At this tutorial site(http://cplus.about.com/library/weekly/aa051202b.htm) it says that to create a string all i have to do is

1) #include <string>

then
2) string thisIsAString

and that's it.

but it doesn't work! i'm sure it's something stupid that i'm doing
i use MS vis. c++ 6.0

thx nick
Avatar of Sys_Prog
Sys_Prog
Flag of India image

That's what u need
What problem r u facing

POst ur code

Amit
#import <string>
using namespace std;

...

string myString;


OR

#import <string>

...

std::string myString;

!!!
Sample code

#include <iostream>
#include <string>

int main () {
       string str1 = "Hello" ;
       string str2 ( "World" ) ;
       string str3 = str1 + str2 ;
       cout << str1 ;
       cout << str2 ;
       cout << str3 ;
}

Amit
ASKER CERTIFIED SOLUTION
Avatar of monkesdb
monkesdb
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
monkesdb,

VC++6.0 doesn't require it
But yep, others do require

Amit
Avatar of nick81
nick81

ASKER

I forgot the namespace, very stupid. thx everyone. monkesdb did mention it so i'll give him the points.
Avatar of nick81

ASKER

vc++ 6.0 doesn't require it? well it didn't work when i didn't use using namespace std;

nick