Библиотека GLib дает мне char**
без какой-либо длины. Как мне перебирать его, печатая каждую строку в массиве?
Я пробовал следующий код, но он дает мне только первую строку, хотя массив содержит несколько строк.
#include <stdio.h>
#include <glib.h>
static gchar** input_files = NULL;
static const GOptionEntry command_entries[] = {
{"input", 'i', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING_ARRAY, &input_files, "Input files", NULL},
{NULL}
};
int main(int argc, char **argv) {
GOptionContext* option_context;
GError* error;
option_context = g_option_context_new(NULL);
g_option_context_add_main_entries(option_context, command_entries, NULL);
if (!g_option_context_parse(option_context, &argc, &argv, &error)) {
g_printerr("%s: %s\n", argv[0], error->message);
return 1;
}
g_option_context_free(option_context);
if (input_files) {
for (int i = 0; input_files[i]; i++) {
printf("%s", input_files[i]);
}
}
}
$ ./a.out -i One Two Three
One
./a.out -i One -i Two -i Three
? - person M.M   schedule 04.11.2019