-
-
Save parzibyte/89c4ba5b64de8305005d6c76465e71c7 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
/* | |
https://parzibyte.me/blog | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#define MAXIMA_LONGITUD_CADENA 100 | |
int main(int argc, char const *argv[]) | |
{ | |
char cadena[MAXIMA_LONGITUD_CADENA] = "Luis Cabrera Benito"; | |
// Desde dónde comenzar a cortar | |
int inicio = 5; | |
// Cuántos caracteres cortar desde "inicio" | |
int cantidadCaracteres = 7; | |
char extraida[MAXIMA_LONGITUD_CADENA] = ""; | |
// Extraer | |
strncpy(extraida, cadena + inicio, cantidadCaracteres); | |
printf("Original: '%s'\n", cadena); | |
printf("Extraída: '%s'\n", extraida); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
En un Buffer como sería