ok, i tried to find the lead and trailing white space and copy the contents in between to a local string, 'temp' through the following code. If i could get it to work, i think i could have taken care of the white space in between, but alas! it does not work either!! here have a look:
Code:
int cleanSpace( char s[])
	{
		int i = 0, first = 0, last = 0; // 'i' - integer for count purpose, first is first non-whitespace character, last- last
						// non-whitespace character.
		char temp[250];			// temp string for saving string 's' without leading and trailing whitespace.
		
		for (i = 0; s[i+1] != ' ' ; i++) // for loop to find the first non-whitespace character and save its position as 'first'.
		{
			if(s[i] != ' ')
			{
				first = i;
			}
		}
		
		for (i = strlen(s); s[i - 1] != ' ' ; i--) // for loop to find the last non-whitespace character and save its position as
		{					   //  'last'.
			if(s[i] != ' ')
			{
				last = i;
			}
		}
		
		for (i = 0; i <= last ; i++)          // for loop to copy all characters in string 's' between 'first' & 'last' to local string
		{				      // 'temp'.
			if(i == last)
			{
				temp[i] = '\0';
			} else {
				temp[i] = s[first];
				first++;
			}
		}
		
                strcpy(temp, s);
		return strlen(temp);
	}