Hi there,
I am trying to obtain values for my variables through the command line. But the values I get for my variables are returning rubbish. Any idea what I am missing here?
Variables:
Code:
static gchar port[1024];
static gchar localhostname[1024] = "";
static gchar challenge[1024] = "";
static gint verbose = 0;
Entries:
Code:
static GOptionEntry entries[] =
{
{ "host", 'h', 0, G_OPTION_ARG_STRING, &localhostname, "Specify the host to connect to", "HOST" },
{ "port", 'p', 0, G_OPTION_ARG_STRING, &port, "Specify the port to connect to", "PORT" },
{ "challenge", 'c', 0, G_OPTION_ARG_STRING, &challenge, "Specify the challenge when connecting", "CHALLENGE"},
{ "test", 't', 0, G_OPTION_ARG_INT, &test, "Specify the challenge when connecting", "TEST"},
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
};
Main:
Code:
GError *error = NULL;
GOptionContext *context;
context = g_option_context_new ("Launch ISR Thin Viewer");
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_print ("Option parsing failed: %s\n", error->message);
exit (1);
}
printf ("My port is: %s\n", &port);
Any ideas? The above function returns me: My port is: ��