Thread: remove spaces from string

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    At the time you return str_buf it points to the last character: '\0'. To free this memory you would need to capture that pointer from remove_space so you can free it main. Edit: that would not work either actually since str_buf has been altered since you malloced it. You could pass a pointer to pointer (**p) to the function as a remedy and alter the original string from within your remove_space function.
    Last edited by Subsonics; 03-19-2013 at 01:28 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. remove redundant white spaces in string
    By ph3s in forum C Programming
    Replies: 16
    Last Post: 03-18-2012, 07:50 PM
  2. Remove a specific char and remove multiple spaces
    By stam in forum C++ Programming
    Replies: 9
    Last Post: 12-18-2010, 07:50 AM
  3. Help remove spaces + punctuation
    By spchehe in forum C++ Programming
    Replies: 10
    Last Post: 11-18-2010, 11:07 AM
  4. How to remove end spaces from string
    By nitinmhetre in forum C Programming
    Replies: 4
    Last Post: 12-16-2006, 01:14 AM
  5. Remove Spaces?
    By 98dodgeneondohc in forum C Programming
    Replies: 15
    Last Post: 04-21-2005, 10:16 AM