www.digitalmars.com         C & C++   DMDScript  

c++ - Using std::string?

reply Kixdemp <Kixdemp_member pathlink.com> writes:
Hello everyone! :-D
OK, here be my code:

-----------------
#include <stdlib.h>
#include <string.h>

int main()
{
string hello("Hellawz!!1");
}
-----------------

And here's my command line:

dmc -mtd -IC:\dm\stlport\stlport dost.cpp

This is what I get on compile:

-----------------
Z:\dost>dmc -mtd -IC:\dm\stlport\stlport dost.cpp
string hello("Hellawz!!1");
^
dost.cpp(6) : Error: undefined identifier 'string'
string hello("Hellawz!!1");
^
dost.cpp(6) : Warning 6: value of expression is not used
--- errorlevel 1

Z:\dost>
-----------------

I tried using std::string, using namespace std, nothing worked... anyone know
how to fix it? Thanks! ;-)
Oct 14 2005
parent reply Bertel Brander <bertel post4.tele.dk> writes:
Kixdemp wrote:
 #include <string.h>
 

strcpy, strcmp, etc. To get C++ stl string use string (note without the .h). E.g: #include <string> using std::string; int main() { string hello("Hellawz!!1"); } -- Absolutely not the best homepage on the net: http://home20.inet.tele.dk/midgaard But it's mine - Bertel
Oct 15 2005
parent reply sulfurik15 gmail.com writes:
Now I get these errors:

------------------------
using _STLP_VENDOR_CSTD::fgetwc;
^
c:\dm\stlport\stlport\cwchar(199) : Error: undefined identifier 'fgetwc'
using _STLP_VENDOR_CSTD::fgetws;
^
c:\dm\stlport\stlport\cwchar(200) : Error: undefined identifier 'fgetws'
using _STLP_VENDOR_CSTD::fputwc;
^
c:\dm\stlport\stlport\cwchar(201) : Error: undefined identifier 'fputwc'
using _STLP_VENDOR_CSTD::fputws;
^
c:\dm\stlport\stlport\cwchar(202) : Error: undefined identifier 'fputws'
using _STLP_VENDOR_CSTD::fwprintf;
^
c:\dm\stlport\stlport\cwchar(210) : Error: undefined identifier 'fwprintf'
Fatal error: too many errors
--- errorlevel 1
------------------------

Do you know how I can fix them? Thanks very much! ;-)

In article <diqg87$1q4n$1 digitaldaemon.com>, Bertel Brander says...
Kixdemp wrote:
 #include <string.h>
 

strcpy, strcmp, etc. To get C++ stl string use string (note without the .h). E.g: #include <string> using std::string; int main() { string hello("Hellawz!!1"); } -- Absolutely not the best homepage on the net: http://home20.inet.tele.dk/midgaard But it's mine - Bertel

Oct 15 2005
parent reply Kixdemp <Kixdemp_member pathlink.com> writes:
Wait a minute... I don't get any of that if I remove the "-mtd" from the command
line... I need this program to work on pure MS-DOS... do you know how to fix it?
Thanks! ;-)
Oct 15 2005
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"Kixdemp" <Kixdemp_member pathlink.com> wrote in message
news:dirc31$2g9a$1 digitaldaemon.com...
 Wait a minute... I don't get any of that if I remove the "-mtd" from the

 line... I need this program to work on pure MS-DOS... do you know how to

The STL doesn't work under MS-DOS. For one thing, it's a little too large to work with the 'tiny' (-mt) memory model, where code+data needs to fit in 64K. You'll need to stick with the functionality in the C headers.
Oct 15 2005
parent Kixdemp <Kixdemp_member pathlink.com> writes:
In article <dirh1n$2k4d$1 digitaldaemon.com>, Walter Bright says...
"Kixdemp" <Kixdemp_member pathlink.com> wrote in message
news:dirc31$2g9a$1 digitaldaemon.com...
 Wait a minute... I don't get any of that if I remove the "-mtd" from the

 line... I need this program to work on pure MS-DOS... do you know how to

The STL doesn't work under MS-DOS. For one thing, it's a little too large to work with the 'tiny' (-mt) memory model, where code+data needs to fit in 64K. You'll need to stick with the functionality in the C headers.

Blah, that stinks! :-( Thanks though! ;-)
Oct 15 2005