CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: problems with strncpy

    Quote Originally Posted by DarkCount
    Hi for all!
    I want to cut last word in the string and then reflect it on the CStatic-component.
    The function "cutting_space", as far as I understand must do cutting of spaces :
    You are using C++, so why are you doing this in such a convoluted way using strcpy(), new, and char pointers/arrays? I can almost bet the program has memory leaks, since you allocate in this "cutting_spaces" function, but nowhere do you delete this memory. And why does "k" take on the magic value of 10? What is the significance of k being equal to 10?

    Why not just copy the passed in string to a CString and use the CString functions to do this work? It is much safer and easier than the code you're showing, and you don't need to allocate anything to do the work.

    Regarcds,

    Paul McKenzie
    Last edited by Paul McKenzie; June 18th, 2006 at 07:08 AM.

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

Featured