Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string question

Status
Not open for further replies.

specv

Programmer
Aug 8, 2001
42
CA
Hi,
what s the include i need to use string and how to delare a string variable?

Thanks

Phil
 
to declare a "string" you want to do

#include <string> // note NOT string.h

or you can also use CStrings


Matt
 
Four posibilities I know of:
1.using MSVCRT:
char* or char[](ex char szTest[YOUR_DESIRED_LENGTH];)
2.using MFC:
CString szTest;
3 using STL:
#include <string>
using namespace std;
sytring sTest;
4.Using ATL COM:
BSTR myStr; //double byte

hope this helps, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
using ATL you can also:
#include<comutil.h>//required for _bstr_t
#include<iostream>//not required for _bstr_t
using namespace std;//not required for _bstr_t
....
//fragment of main:
_bstr_t x;
x = &quot;hello &quot;;
x += L&quot;people&quot;;
cout<<(char*)x<<endl;
wcout<<(BSTR)x<<endl; Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top