fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void trim(char **s) {
  6. while ((*s)[0] == ' ') (*s)++;
  7. int max = strlen(*s);
  8. while ((*s)[--max] == ' ');
  9. (*s)[max+1] = '\0';
  10. }
  11. int main() {
  12. char *s = " asdf fdsa fdsa ";
  13. printf("\"%s\"\n", s);
  14. trim(&s);
  15. printf("\"%s\"\n", s);
  16.  
  17. return 0;
  18. }
Runtime error #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
Standard output is empty