|
-
Oct 10th, 2002, 11:15 PM
#1
Thread Starter
Hyperactive Member
string functions help
how would i use
.insert
.erase
.find
on a string. i found references on them, but not how to use them.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 11th, 2002, 05:54 AM
#2
Code:
// for convenience:
typedef string::size_type off;
// a string:
string str1("abcdefgh");
// get the offset of the letter d
off o1 = str1.find('d');
// insert some other characters there
str1.insert(o1, "Hello there!");
cout << str1;
// erase the last 3 characters:
str1.erase(str1.end()-3, str1.end());
Search MSDN, they have examples on these functions.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 11th, 2002, 07:33 PM
#3
Thread Starter
Hyperactive Member
btw i get
error C2653: 'string' : is not a class or namespace name
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 11th, 2002, 07:57 PM
#4
Monday Morning Lunatic
Code:
#include <string>
using namespace std;
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 11th, 2002, 09:00 PM
#5
Thread Starter
Hyperactive Member
just created more errors,
int __stdcall PStrReplace(char* lpString,char* lpFind,char* lpReplace,string *lpbuffer)
off StringLv = lpbuffer.find('d');
F:\C++\newprojects\Quser32\QUSER32.cpp(27) : error C2228: left of '.find' must have class/struct/union type
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 12th, 2002, 02:46 AM
#6
Monday Morning Lunatic
Use a reference, not a pointer (i.e. string &buffer). If you're following the Hungarian naming convention then drop the "lp" as well.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|