Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I use the standard string class?

0 views
Skip to first unread message

SSchwe3872

unread,
Jul 9, 2000, 3:00:00 AM7/9/00
to
I'm trying to write a console program in Visual C++ 6.0, using the console
option. Although I read in the FAQ for another group, "Try creating a new
project or application to target MS-DOS, QuickWin or Win32 Console depending on
your compiler version. You can then use the Standard C and C++ libraries to
write strictly conforming programs," I cannot seem to use the standard C++
string class; in other words, typing, "#include <string>" and then declaring a
variable of type string or string* does not work. I don't know if the string
class is included in Visual C++ 6.0 (Visual Studio) or not. If it is, how can
I use it? If not, does Visual C++ have its own string class I can use instead?
I have been told that MFC or ATL does, but I don't want to use those or
anything else that would require me to write a Windows program--I just want to
write a console program. I hate using char*, and it seems like there should be
some alternative. [By the way, I've had success using other standard header
files like iostream.h; it's just string I'm having a problem with.] Thanks for
any advice.

Torsten Robitzki

unread,
Jul 9, 2000, 3:00:00 AM7/9/00
to
Hellp SSchwe3872 (funny name:-)
the class the string live in the namespace std, so the name of the pet is
std::string.
For example
#include <string>
std::string s = "Hello Wold";
Greeds Torsten

SSchwe3872 schrieb:

torsten.robitzki.vcf

Al.Fastekovski

unread,
Jul 10, 2000, 3:00:00 AM7/10/00
to

#include <string>

using namespace std;

void main(void)
{
string MyStr;
MyStr = "asdfasdf";
and so on.....
}


Craig Powers

unread,
Jul 10, 2000, 3:00:00 AM7/10/00
to
SSchwe3872 wrote:

[...]

> [By the way, I've had success using other standard header
> files like iostream.h; it's just string I'm having a problem with.]
> Thanks for any advice.

FYI, iostream.h is NOT a standard header; the standard header is
<iostream>, <iostream.h> implements "classical" iostreams. (I'm not
sure what exactly what the differences are aside from namespace, but
since the documentation makes a distinction I don't doubt they exist.)

See the two previous replies for the answer to your main question.

James Curran

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to

"Craig Powers" <eni...@hal-pc.org> wrote in message
news:396A0522...@hal-pc.org...

>
> FYI, iostream.h is NOT a standard header; the standard header is
> <iostream>, <iostream.h> implements "classical" iostreams. (I'm not
> sure what exactly what the differences are aside from namespace, but
> since the documentation makes a distinction I don't doubt they exist.)

Most notably, <iostream.h> doesn't understand std::string, nor UNICODE
characters. I think the manipulators are also a bit different.

--
Truth,
James Curran
http://www.NJTheater.com (Professional)
http://www.NovelTheory.com (Personal)
http://www.BrandsForLess.com (Day Job)


0 new messages