Solved

String (newb)

Posted on 2004-04-15
7
234 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
Comment Utility
That's what u need
What problem r u facing

POst ur code

Amit
0
 
LVL 3

Expert Comment

by:monkesdb
Comment Utility
#import <string>
using namespace std;

...

string myString;


OR

#import <string>

...

std::string myString;

!!!
0
 
LVL 10

Expert Comment

by:Sys_Prog
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Accepted Solution

by:
monkesdb earned 50 total points
Comment Utility
Sys_Frog

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

Expert Comment

by:Sys_Prog
Comment Utility
monkesdb,

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

Amit
0
 

Author Comment

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

Author Comment

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

nick
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now