-
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?
-
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 "?
-
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
-
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