LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Function to delete trailing space of a string

    I can use the codes below to fulfill this function, however, I 'm more happy if CVI already has provided the same function.
 
Thanks!
Jacky
 
 
void RemoveTrailingSpaces(char *string)
{
 int len = strlen(string);
 char *ptr=NULL;
 if (len)
 {
  ptr = string + len - 1; // Point to last char -right before NULL-
  
  while (*ptr == ' ' && ptr > string)
  {
   *(ptr) = 0;
   ptr--;
  }
 }
 
 printf("%s",string);
 len=strlen(string);
 printf("\n%d",len);
 Delay(3);
 
 
}
0 Kudos
Message 1 of 2
(3,495 Views)
In the programmers toolbox there is the RemoveSurroundingWhiteSpace() function which is similar, but will also remove any leading white space.  There are a few other string manipulation routines that are also in the toolbox, but not one that removes only the trailing white space.
0 Kudos
Message 2 of 2
(3,485 Views)