Created
June 16, 2012 23:47
-
-
Save josejuan/2942873 to your computer and use it in GitHub Desktop.
Buscando ceros...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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