-
-
Save parzibyte/ac99b484af07e34e556e74b62f481fff 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> | |
#include <string.h> // strncpy | |
#define MAXIMA_LONGITUD_CADENA 50 | |
int main(void) { | |
char nombre[MAXIMA_LONGITUD_CADENA] = "Luis"; | |
char temporal[MAXIMA_LONGITUD_CADENA] = ""; | |
// Copia a temporal, lo que hay en nombre, pero solo copia 1 caracter | |
strncpy(temporal, nombre, 1); | |
printf("Nombre: %s. Temporal: %s", nombre, temporal); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment