Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's fairly redundant.

    char *p;
    while (p = strchr(tmpfn, ' '))
        *p = '_';


I love that the O(n^2 / 2) algorithm for this problem is modded 4x the O(n) one.


If you meant to be O(n), you should have used p=strchr(p,' ') for the next-iteration part of your for loop.


I didn't write that code, Google did. I wonder if the person who wrote it can figure out how many golf balls fit in a school bus?


OW MY BRAIN.

  char *cp = NULL;
  for(cp = tmpfn; cp && *cp; cp++)
    if(isspace(*cp))
      *cp = '_';


char cp = tmpfn; for(; cp; cp++) if(cp == ' ') cp = '_';

my brain too




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: