Last active
September 13, 2019 15:34
-
-
Save parzibyte/55a2d41f7fee5b4519fd27baf60b8748 to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
/* | |
Longitud de una cadena en C | |
https://parzibyte.me/blog | |
*/ | |
int main(void) { | |
char* cadena = "Hola, mundo. Programando en C desde parzibyte.me"; | |
int contador = 0; | |
// Recorrer la cadena hasta encontrar el carácter NUL o de terminación | |
while (cadena[contador] != 0) { | |
contador++; | |
} | |
printf("La longitud de '%s' es %d", cadena, contador); | |
/* | |
Salida: | |
La longitud de 'Hola, mundo. Programando en C desde parzibyte.me' es 48 | |
*/ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment