Thread: Space problem...Pls help

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    2

    Space problem...Pls help

    Edit - I deleted my last post since i fixed it 1 minute ago hehe needed some timeout to think straight

    Never mind lol i fixed the problem myself.

    But i have a new question.

    I have

    6 - 10 well a number of spaces at the end of eg.

    1 2 3 10 1400 1939 88 _ _ _ _ _ _ _ _ <- these are spaces.

    How do i remove them?

    I reading about trim but it ain't really clicking at the moment.

    Does making array[i]=0 work? or NULL?
    Care to share any knowledge about this anyone?
    Last edited by Helmet_King; 04-06-2006 at 11:53 PM. Reason: Changing some values

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    if array is a char array, then array[i] = 0; will terminate the string at that position.

    Your question is vague and confusing, you have a number of spaces at the end of what, exactly?
    is 1 2 3 10 1400 1939 88 a string, as in "1 2 3 10 1400 1939 88 "?

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2
    O um i try explain it more.

    Its like

    just each array of character

    Like

    array 0 = 1
    array 1=' '
    array 2= 2
    array 3=3
    array 4=' '
    array 5=6

    1 23 6

    Um i hope that explains it...

    like my code atm replaces these numbers to bigger/smaller numbers so it does a moving function which moves array up and down.

    Down is fine cause im making it larger. But when i move it up it chucks empty spaces in the end.

    so wen

    10 changes to 6 eg.

    1 0 _ 1
    6 _ 1 _

    So yea hope this is less vague

  4. #4
    Registered User wintellect's Avatar
    Join Date
    Mar 2006
    Posts
    24
    You could try this:

    make empty entries a NULL, then malloc memory and copy non NULL chars to the malloc'd memory one-by-one
    Last edited by wintellect; 04-07-2006 at 03:42 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. c graphics problem ( pls help )
    By abhijeetnayak in forum C Programming
    Replies: 4
    Last Post: 05-23-2006, 11:37 AM
  3. hi guys, pls help me with this problem
    By amits in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2004, 08:12 PM
  4. FPS Problem, pls help
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 06-21-2002, 12:03 PM
  5. Spot the problem..a test question, pls help!
    By Unregistered in forum C++ Programming
    Replies: 10
    Last Post: 02-05-2002, 01:40 AM