where to find string class

R

Robin

I am a c++ beginner and was wonder if anyone knows of where I can find
a c++ string class for download that is easy to use for creating
strings, arrays of strings, and manipulating strings....

Thank you,
-Robin
 
R

Robin

Can you or someone give me an example of how to include this library
and how to use it to create strings and arrays of them?

Thanks,
-Robin
 
I

Ian Collins

On 03/13/10 12:15 PM, Robin wrote:

[please don't top-post]
> Can you or someone give me an example of how to include this library
> and how to use it to create strings and arrays of them?
>
You include the headers that declare the library classes and function,
you don't include a library. The linker combines your code with the
appropriate libraries at link time. Your tool should do all that for
you, so you don't have to worry about the details.

Just include <string> for strings and <vector> for vectors. Your C++
book should have made this clear.
 
D

Default User

Robin wrote:

Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
Can you or someone give me an example of how to include this library
and how to use it to create strings and arrays of them?


Here's one site with some information about std::string:

<http://www.cplusplus.com/reference/string/string/>



Brian
 
R

Robin

Leigh said:
Robin said:
Can you or someone give me an example of how to include this library
and how to use it to create strings and arrays of them?

Thanks,
-Robin

#include <vector>
#include <string>
#include <iostream>

int main()
{
std::vector<std::string> someStrings;
someStrings.push_back("apples");
someStrings.push_back("oranges");
std::cout << "first string: " << someStrings[0] << std::endl;
std::cout << "second string: " << someStrings[1] << std::endl;
}

outputs:

first string: apples
second string: oranges

/Leigh

thanks for your help....I tried the code and found I didn't have
either library, std::string or std::vector installed.

Where can I find and download and install these two?

Thanks,
-Robin
 
I

Ian Collins

Leigh said:
Robin said:
Can you or someone give me an example of how to include this library
and how to use it to create strings and arrays of them?

Thanks,
-Robin

#include<vector>
#include<string>
#include<iostream>

int main()
{
std::vector<std::string> someStrings;
someStrings.push_back("apples");
someStrings.push_back("oranges");
std::cout<< "first string: "<< someStrings[0]<< std::endl;
std::cout<< "second string: "<< someStrings[1]<< std::endl;
}

thanks for your help....I tried the code and found I didn't have
either library, std::string or std::vector installed.

They aren't libraries, they are headers. Do you have a C++ compiler
installed? They should be were the compiler knows to find them if you have.
>
> Where can I find and download and install these two?

With your compiler.
 
R

Robin

can you point me to a web site where I can download these two headers,
though...I don't have them, they did not come with openwatcom compiler
or devc++. Thanks,
-Robin

Ian said:
Leigh said:
Can you or someone give me an example of how to include this library
and how to use it to create strings and arrays of them?

Thanks,
-Robin


#include<vector>
#include<string>
#include<iostream>

int main()
{
std::vector<std::string> someStrings;
someStrings.push_back("apples");
someStrings.push_back("oranges");
std::cout<< "first string: "<< someStrings[0]<< std::endl;
std::cout<< "second string: "<< someStrings[1]<< std::endl;
}

thanks for your help....I tried the code and found I didn't have
either library, std::string or std::vector installed.

They aren't libraries, they are headers. Do you have a C++ compiler
installed? They should be were the compiler knows to find them if you have.
Where can I find and download and install these two?

With your compiler.
 
R

Robin

Robin said:
can you point me to a web site where I can download these two headers,
though...I don't have them, they did not come with openwatcom compiler
or devc++. Thanks,
-Robin

Ian said:
Leigh Johnston wrote:
Can you or someone give me an example of how to include this library
and how to use it to create strings and arrays of them?

Thanks,
-Robin


#include<vector>
#include<string>
#include<iostream>

int main()
{
std::vector<std::string> someStrings;
someStrings.push_back("apples");
someStrings.push_back("oranges");
std::cout<< "first string: "<< someStrings[0]<< std::endl;
std::cout<< "second string: "<< someStrings[1]<< std::endl;
}

thanks for your help....I tried the code and found I didn't have
either library, std::string or std::vector installed.

They aren't libraries, they are headers. Do you have a C++ compiler
installed? They should be were the compiler knows to find them if you have.
Where can I find and download and install these two?

With your compiler.

Nevermind, I have these classes....but for some reason

// my first string
#include <iostream>
#include <string>

using namespace std;

int main () {
string a;
a = "f";
cout << a;
return 0;

}


doesn't compile on windows 7 with the open watcom compiler at
all....does anyone offhandedly know why it won't compile on windows 7
home premium using openwatcom.... Thanks
 
L

LR

Robin wrote:

// my first string
#include <iostream>
#include <string>

using namespace std;

int main () {
string a;
a = "f";
cout << a;
return 0;

}


doesn't compile on windows 7 with the open watcom compiler at
all....does anyone offhandedly know why it won't compile on windows 7
home premium using openwatcom.... Thanks

Can you say which version you are using?

What error messages you're getting?

Perhaps the last question in this faq
http://www.openwatcom.org/index.php/Open_Watcom_FAQ would be useful?

Or this http://www.openwatcom.org/index.php/Open_Watcom_STL

LR
 
J

James Kanze

On 03/13/10 12:15 PM, Robin wrote:

[...]
You include the headers that declare the library classes and
function, you don't include a library. The linker combines
your code with the appropriate libraries at link time. Your
tool should do all that for you, so you don't have to worry
about the details.

You do have to be sure that you're linking the code as a C++
program. I'm not familiar with OpenWatcom (the compiler cited
by the original poster); but, for example, with gcc, you have
to use g++ to invoke the linker if you want things to happen
automatically: using gcc or ld requires explicitly specifying
the C++ libraries.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top