View previous topic :: View next topic
|
Author |
Message |
Laxminarsimharao
New User
Joined: 08 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
I have one string with the length of 80 (X(80)). the data comming in that string might contain Spaces in any place.
I need to eliminate the spaces before the data and after the data, also i need to eliminate the spaces in between data, only one spaces should be places in between the data.
Example:
Name Pic X(80)
Data in Name like below:
' ARUN RAJPAL '
'ARUN RAJPAL '
I need output like below:
'ARUN RAJPAL '
Data in Name like below:'ARUN RAJ PAL '
I need output like below:
'ARUN RAJ PAL '
Please help me out. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Given the variety of possible input data and the requirement to ensure one space between each name component, i'd suggest defining 2 arrays (one of the input and one for the output) and looping across the input one byte at a time, moving all of the needed bytes to the output array - skipping leading, trailing and multiple-embedded spaces. |
|
Back to top |
|
|
|