Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

String (newb)

Posted on 2004-04-15
7
263 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:nick81
  • 3
  • 2
  • 2
7 Comments
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10832960
That's what u need
What problem r u facing

POst ur code

Amit
0
 
LVL 3

Expert Comment

by:monkesdb
ID: 10832965
#import <string>
using namespace std;

...

string myString;


OR

#import <string>

...

std::string myString;

!!!
0
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10832971
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
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Accepted Solution

by:
monkesdb earned 50 total points
ID: 10832985
Sys_Frog

you still need to state which namespace it's in !!!
0
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10833222
monkesdb,

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

Amit
0
 

Author Comment

by:nick81
ID: 10833269
I forgot the namespace, very stupid. thx everyone. monkesdb did mention it so i'll give him the points.
0
 

Author Comment

by:nick81
ID: 10833282
vc++ 6.0 doesn't require it? well it didn't work when i didn't use using namespace std;

nick
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question