Re:Android is a screwed, hard-coded, non-portable abomination.
by tptacek on Thursday November 05, 2009 @07:49PM
(#925170)
OW MY BRAIN.
[ Parent
| on HN ]
Re:Android is a screwed, hard-coded, non-portable abomination.
by rntz on Thursday November 05, 2009 @08:02PM
(#925186)
That's fairly redundant.
char *p;
while (p = strchr(tmpfn, ' '))
*p = '_';
Re:Android is a screwed, hard-coded, non-portable abomination.
by tptacek on Friday November 06, 2009 @12:34AM
(#925506)
I love that the O(n^2 / 2) algorithm for this problem is modded 4x the O(n) one.
Re:Android is a screwed, hard-coded, non-portable abomination.
by jongraehl on Friday November 06, 2009 @02:10AM
(#925623)
If you meant to be O(n), you should have used p=strchr(p,' ') for the next-iteration part of your for loop.
Re:Android is a screwed, hard-coded, non-portable abomination.
by tptacek on Friday November 06, 2009 @02:16AM
(#925627)
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?
Re:Android is a screwed, hard-coded, non-portable abomination.
by tptacek on Thursday November 05, 2009 @08:20PM
(#925214)
OW MY BRAIN.
char *cp = NULL;
for(cp = tmpfn; cp && *cp; cp++)
if(isspace(*cp))
*cp = '_';
Re:Android is a screwed, hard-coded, non-portable abomination.
by jagjit on Thursday November 05, 2009 @09:57PM
(#925339)
char cp = tmpfn;
for(; cp; cp++)
if(cp == ' ')
cp = '_';
my brain too
Re:Android is a screwed, hard-coded, non-portable abomination.
by ComputerGuru on Thursday November 05, 2009 @07:53PM
(#925177)
You're replacing all spaces in a string with underscores, until you reach the end of a string or there are no spaces left...
Cool. But what does this have to do with the article? (I apologize if I'm missing something, it is 3am afterall)
Re:Android is a screwed, hard-coded, non-portable abomination.
by sofal on Thursday November 05, 2009 @08:03PM
(#925187)
What's the purpose of the "&& *p"? Would strchr ever return a pointer to a null terminator?
Re:Android is a screwed, hard-coded, non-portable abomination.
by oipuyjhg on Thursday November 05, 2009 @08:14PM
(#925205)
Yes if you pass it a pointer to a null string
Re:Android is a screwed, hard-coded, non-portable abomination.
by tptacek on Thursday November 05, 2009 @08:30PM
(#925232)
NULL is how strchr tells you the character you're looking for isn't present. (Yes, the *p check is also superfluous).
Kids these days.