Debug Assertion Failure?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gone With Wind

    Debug Assertion Failure?

    I am a novice of C++. I write the following code to append strings to
    a Combox (m_RibNum). This control component is on a PropertyPage
    hosted on a PropertySheet.

    int i;
    char buffer[10];
    CString s
    for (i=0;i<5;i++)
    {
    itoa(i+1,buffer ,10);
    s=*buffer;
    sheet.m_RibType Edit.m_RibNum.A ddString((LPCTS TR)s);
    }

    When I debug this code, Debug Assertion Failure occured. Could anybody
    tell me what's wrong in my code please?
  • Ian Collins

    #2
    Re: Debug Assertion Failure?

    Gone With Wind wrote:
    I am a novice of C++. I write the following code to append strings to
    a Combox (m_RibNum). This control component is on a PropertyPage
    hosted on a PropertySheet.
    >
    int i;
    char buffer[10];
    CString s
    for (i=0;i<5;i++)
    {
    itoa(i+1,buffer ,10);
    s=*buffer;
    sheet.m_RibType Edit.m_RibNum.A ddString((LPCTS TR)s);
    }
    >
    You'd have better luck on a windows group, none of those functions or
    classes are standard C++.

    --
    Ian Collins.

    Comment

    • James Kanze

      #3
      Re: Debug Assertion Failure?

      On May 25, 1:51 am, Gone With Wind <XinMen...@gmai l.comwrote:
      I am a novice of C++. I write the following code to append strings to
      a Combox (m_RibNum). This control component is on a PropertyPage
      hosted on a PropertySheet.
      int i;
      char buffer[10];
      CString s
      for (i=0;i<5;i++)
      {
      itoa(i+1,buffer ,10);
      s=*buffer;
      sheet.m_RibType Edit.m_RibNum.A ddString((LPCTS TR)s);
      }
      When I debug this code, Debug Assertion Failure occured. Could
      anybody tell me what's wrong in my code please?
      As others have already pointed out, there's not much C++ in
      there to go on. Just guessing about what the code does,
      wouldn't something like:

      for ( int i = 0 ; i < 5 ; ++ i ) {
      std::istringstr eam s ;
      s << i ;
      shee.m_RibTypeE dit.m_RibNum.Ad dString(
      toCString( s.str() ) ) ;
      }

      be more what you are looking for. (I'm not too sure about how
      to convert a string to a CString, but if CString is some sort of
      text string, there's a good chance that CString( s.str().c_str() ), or
      even just CString( s.str() ) would do the trick here.)

      --
      James Kanze (GABI Software) email:james.kan ze@gmail.com
      Conseils en informatique orientée objet/
      Beratung in objektorientier ter Datenverarbeitu ng
      9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

      Comment

      Working...