Does This Code Make Me Look Obfuscated?

len = strlen(str);
i = 0;
while(str[0]) {
   while(str[i] == ' ') {
      i++;
      }
   str[0] = str[i];
   str++; 
}
str -= len - i;


Obfuscated enough? I'd love to hear how this stacks up relative to the other two (or if it even works correctly, for that matter). It probably isn't much of an improvement over the other two methods (if it's an improvement at all), but it does it with one (incrementing) variable and without strcpy. Also, i ends up holding the value of the total white space removed, for what it's worth.

This isn't how I'd tend to solve the problem if I came upon it on my own, though.. I'd use two strings, cycle through the source string and copy non-white characters, and then return the second string or strcpy it into the first.




RESULTS:

I ran the four algorithms (A: Teacher's, B: XCthu's, C: Mine, and D: muni's) repeatedly for five seconds with a variety of input.

All algorithms were successfuly able to remove all whitespace from all strings.

String: 'The quick brown fox jumps over the lazy dog.'
A: 1.49 Million
B:  .98
C: 1.42
D: 1.44

String: 'A B'        String: ' '           String: 'AAAAA etc.' (~1024 long)
A: 8.23 Million      A: 10.39 Million      A:   85.36 Thousand
B: 7.77              B:  9.85              B:  107.69
C: 7.13              C:  8.65              C:   77.54
D: 8.38              D: 10.51              D:   78.55

String: 'i  a m  t h e  v e r y  etc.'     String: 'AAAAA etc.' (~128 long)
A: 628.15 Thousand                         A:  667.29 Thousand
B: 138.16                                  B:  830.62
C: 625.33                                  C:  602.97
D: 655.06                                  D:  616.14

String: 'this is a string with normal words etc.' (~1024 long)
A: 80.22 Thousand
B:  5.13
C: 78.83
D: 78.34

String: 'a           b       c              etc.' (~1024 long)
A: 55.88 Thousand
B:  1.02
C: 58.16
D: 58.92
Run on a G4/400. There was lots of overhead for setting up, measuring, and recording the results, so the functions could be expected to go much faster in actual use.

The tests tested strings with 'normal' spacing (like a text paragraph), strings with no spacing, and strings with vast spaces.

Fastest algorithms for each string are marked in bold. Second fastest is in italics.

munificent: Algorithm A correctly removes long strings of whitespace, and Algorithm C makes 'str' point to the beginning of the string with the last line.

eos: I ran yours through a few tests. It runs about 1/3 the speed of A, C, and D in nearly solid strings, 1/2 the speed in normaly spaced strings... and easily twice as fast as anything else where spaces are the predominant character. Nice.