Inicializar una Matriz de Strings en C
https://www.delftstack.com/es/howto/c/array-of-strings-in-c/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MAX_LENGTH 100
#define NUM_STRINGS 10
int main(){
char arr2[NUM_STRINGS][MAX_LENGTH] = { {"first string"},
{"second string"},
{"third string"},
{"fourth string"},
{"fifth string"} };
for (int i = 0; i < NUM_STRINGS; ++i) {
printf("%s, ", arr2[i]);
}
exit(EXIT_SUCCESS);
}
Ejecución
first string, second string, third string, fourth string, fifth string, , , , , ,
No hay comentarios:
Publicar un comentario