Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 2, 2021 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/89c4ba5b64de8305005d6c76465e71c7 to your computer and use it in GitHub Desktop.
Save parzibyte/89c4ba5b64de8305005d6c76465e71c7 to your computer and use it in GitHub Desktop.
/*
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;
}
@alejandromora2507
Copy link

En un Buffer como sería

@parzibyte
Copy link
Author

Si tiene alguna consulta puede hacérmela llegar en https://parzibyte.me/#contacto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment