Results 1 to 6 of 6

Thread: Need help with C++ string parasing and general help, help me please :)

  1. #1

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130

    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!

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341

    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;
        }  
    }

  3. #3
    jim mcnamara
    Guest
    PHP Code:
    void _stdcall ReverseStringBSTR a 

       
    int iiLen
      
    BSTR b
      
    LPSTR pApB;   string pointers

      iLen 
    strlen( (LPCSTR));   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
      
    SysAllocStringLenNULLiLen );  create b memory for same length as a

       pA 
    = (LPSTR)a;         pA points to start of a string
       pB 
    = (LPSTR)iLen -1;   pB points to end of b (currently empty)

        for ( 
    0iLeni++ )  each char from a -> b backwards
          
    *pB-- = *pA++; 

       
    pA = (LPSTR)a;  reset pointer to the start of strings
       pB 
    = (LPSTR)b

       for ( 
    0iLeni++ )  copy b to a char by char
          
    *pA++ = *pB++; 

        
    SysFreeString);  free memory allocated for b earlier

    the 
    'a' string now is reversed.


  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130
    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
  •  



Click Here to Expand Forum to Full Width