Skip to content

Instantly share code, notes, and snippets.

@antirez
Created January 21, 2013 12:16
Show Gist options
  • Select an option

  • Save antirez/4585656 to your computer and use it in GitHub Desktop.

Select an option

Save antirez/4585656 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(void) {
unsigned char *p = "$123\r\n";
int len = 0;
p++;
while(*p != '\r') {
len = (len*10)+(*p - '0');
p++;
}
/* Now p points at '\r', and the len is in bulk_len. */
printf("%d\n", len);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment