|
-
Sep 13th, 2001, 04:08 PM
#1
Thread Starter
Addicted Member
Need help with C++ string parasing and general help, help me please :)
Here are my few questions:
1. What are the equalent version of Goto, Exit Sub/function, and select case?
2. How can I pass the state of a checkbox to c++ dll function ( like chk.Value = 1)?
3. Can anyone explain whats going on in this code step by step please.
void _stdcall ReverseString( BSTR a )
{
int i, iLen;
BSTR b;
LPSTR pA, pB;
iLen = strlen( (LPCSTR)a );
b = SysAllocStringLen( NULL, iLen );
pA = (LPSTR)a;
pB = (LPSTR)b + iLen -1;
for ( i = 0; i < iLen; i++ )
*pB-- = *pA++;
pA = (LPSTR)a;
pB = (LPSTR)b;
for ( i = 0; i < iLen; i++ )
*pA++ = *pB++;
SysFreeString( b );
}
4. Whats the bug in CString. And what is meant by C style string?
Thanx in advance!
-
Sep 13th, 2001, 04:16 PM
#2
Frenzied Member
700th Post, YAY :D
a select case (as known in vb) is a switch statment in C++
Code:
int nNumber;
switch (nNumber) {
case 0: {
// Do Whatever
break;
}
case 1: {
// Do Whatever
break;
}
}
-
Sep 13th, 2001, 04:44 PM
#3
PHP Code:
void _stdcall ReverseString( BSTR a )
{
int i, iLen;
BSTR b;
LPSTR pA, pB; string pointers
iLen = strlen( (LPCSTR)a ); how long is the a string
// i'd add this line here if(iLen <2) return; -- don't mess if only 1 or zero chars
b = SysAllocStringLen( NULL, iLen ); create b memory for b - same length as a
pA = (LPSTR)a; pA points to start of a string
pB = (LPSTR)b + iLen -1; pB points to end of b (currently empty)
for ( i = 0; i < iLen; i++ ) each char from a -> b backwards
*pB-- = *pA++;
pA = (LPSTR)a; reset pointer to the start of strings
pB = (LPSTR)b;
for ( i = 0; i < iLen; i++ ) copy b to a char by char
*pA++ = *pB++;
SysFreeString( b ); free memory allocated for b earlier
the 'a' string now is reversed.
}
-
Sep 13th, 2001, 04:44 PM
#4
Exit Sub/Function in VB = return in C/C++.
if the return type of the function is void, then no return value needs to be specified, otherwise you need to return a value of the specified type.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 14th, 2001, 05:25 AM
#5
Monday Morning Lunatic
4. The bug in CString was a repeated-allocation memory leak. It has since been fixed Incidentally, some RogueWave implementations of the standard library string class had the same type of bug.
CString is MFC
string is from the Standard C++ Library
A "C Style" string is merely an array with a NULL at the end of it to show where the string ends.
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
-
Sep 14th, 2001, 07:05 PM
#6
Thread Starter
Addicted Member
thanx for the help u guys are great!
There is another question
cpp file:
MYTESTDLLEXIM void _stdcall StrTest( char* FirstParam, char* SecondParam )
{
strcat(FirstParam,SecondParam);
}
def file:
StrTest @3
Giving me bad calling convention or something
I'm trying to make an string function.
Thanx in advance!
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
|