Program to generate an xml file based on a provided text file
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
499 B

  1. #include <string.h>
  2. #include <ctype.h>
  3. char *trim(char *str) {
  4. char *end;
  5. /* Trim leading space */
  6. while (isspace((unsigned char) *str)) {
  7. str++;
  8. }
  9. if(*str == 0) {
  10. /* All spaces? */
  11. return str;
  12. }
  13. /* Trim trailing space */
  14. end = str + strlen(str) - 1;
  15. while (end > str && (isspace((unsigned char) *end) || *end == '\r' || *end == '\n')) {
  16. end--;
  17. }
  18. /* Write new null terminator */
  19. *(end + 1) = 0;
  20. return str;
  21. }