Solved

String (newb)

Posted on 2004-04-15
7
278 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

691 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