Solved

String (newb)

Posted on 2004-04-15
7
256 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find boost header files using gnu make (MinGW) on Win 7 11 88
sorting efficency of sorting algorithm 30 113
Path to  STL Map header file 1 58
C++ mouse_event mouse look 7 84
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

832 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