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 manipulation

Status
Not open for further replies.

kook04

Programmer
Jun 26, 2001
58
US
Hello all.

This is a beginner question, but I am a Java programmer, and String manipulation in C++ just isn't the same. My question is this:

Is there a way to convert an array of characters to a &quot;basic string&quot;? I.E. the <string> class has functions that I would like to use like find( ), etc, and I need to convert in order to do so.

Thanks everyone.

Kennedy ------
KJR
 
I have not used <string> for a few years but I believe sprintf(your_string,&quot;%s&quot;,your_character_array); will still work with it. I am not 100% though. I have been using CString for a while now.


Matt
 
#include<string>
using namespace std;
int main()
{
string x;
x=&quot;hello &quot;;
x+=&quot;world&quot;;
if(x==&quot;hello world&quot;){.....}
int i=x.find(world);
if(i!=-1){....}
return 0;
} John Fill
1c.bmp


ivfmd@mail.md
 
For strings you have three posibities:
- char* and char[] (or LPSTR)
- string from <string> na dnamespace std
- CString in MFC from <afx.h>

The most convenient for operations is I think is CString.(my oppinion)


s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Don't forget, CSrting yoou can;t use without using MFC. The portable one is string. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top