V
Verrigan
I'm trying to pass an array to a function, and change the values of that
array, but I can't seem to figure it out.. Please help me figure out what
I'm doing wrong... Any help would be appreciated... Even if it's "You can't
change the value of a passed array." Thanks!
Code:
static int get_command_args(char *msg, char **args)
{
char *p;
int i, loops;
i = 0;
loops = 0;
p = args;
while(*msg && !(*msg == END_CHAR)) {
loops++;
fprintf(stdout, "%d\n", loops);
*p++ = *msg++;
if(*msg == ARG_CHAR) {
i++;
*p = '\0';
p = args;
*msg++;
}
}
return i;
}
static int parse_command(int sock, char *msg)
{
char *args[10];
char buf[BUFFER_LEN];
get_command_args(msg, args);
...
gdb debugging info:
0x0804922e in get_command_args (msg=0xbfffe530
"login§verrigan§82jsheud¶\n", args=0xbfffe0c0) at interface.c:65
65 *p++ = *msg++;
(gdb) back
#0 0x0804922e in get_command_args (msg=0xbfffe530
"login§verrigan§82jsheud¶\n", args=0xbfffe0c0) at interface.c:65
#1 0x08049280 in parse_command (sock=9, msg=0xbfffe530
"login§verrigan§82jsheud¶\n") at interface.c:81
array, but I can't seem to figure it out.. Please help me figure out what
I'm doing wrong... Any help would be appreciated... Even if it's "You can't
change the value of a passed array." Thanks!
Code:
static int get_command_args(char *msg, char **args)
{
char *p;
int i, loops;
i = 0;
loops = 0;
p = args;
while(*msg && !(*msg == END_CHAR)) {
loops++;
fprintf(stdout, "%d\n", loops);
*p++ = *msg++;
if(*msg == ARG_CHAR) {
i++;
*p = '\0';
p = args;
*msg++;
}
}
return i;
}
static int parse_command(int sock, char *msg)
{
char *args[10];
char buf[BUFFER_LEN];
get_command_args(msg, args);
...
gdb debugging info:
0x0804922e in get_command_args (msg=0xbfffe530
"login§verrigan§82jsheud¶\n", args=0xbfffe0c0) at interface.c:65
65 *p++ = *msg++;
(gdb) back
#0 0x0804922e in get_command_args (msg=0xbfffe530
"login§verrigan§82jsheud¶\n", args=0xbfffe0c0) at interface.c:65
#1 0x08049280 in parse_command (sock=9, msg=0xbfffe530
"login§verrigan§82jsheud¶\n") at interface.c:81