Skip to content

Instantly share code, notes, and snippets.

@josejuan
Created June 16, 2012 23:47
Show Gist options
  • Save josejuan/2942873 to your computer and use it in GitHub Desktop.
Save josejuan/2942873 to your computer and use it in GitHub Desktop.
Buscando ceros...
// Buscando un cero (eg. la longitud de la cadena)
int strlen(char *s) {
int l = 0;
while(*s++) l++;
return l;
}
// Buscando la primera aparición de un caracter dado
int strpos(char *s, char c) {
int l = 0;
while(*s != c && *s++) l++;
return *s == c ? l : -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment