-
Hello again
I was trying for a while understading but i can't figured it out.
When i get this code
Code:
char op[]="cr test";
//teste(op);
char **comando=teste(op);
printf("COMANDO1: %s\n",comando[0]);
it work nice comando[0] is cr and comando[1] is test.
but i i put
Code:
char op[]="p 1 3";
//teste(op);
char **comando=teste(op);
char *com=comando[0]; /*it will be "p"
int *x=comando[1];/*should be 1
int *y=comando[2];/*should be 3
printf("comando:%s %d %d\n",com,x,y);
don't work as i expect.
it does like this
Letrorium>p 1 3
comando:p -1081791238 -1081791236
why?
-
That code will not produce the output you describe. In fact, the code won't even compile because of type mismatches.
The statement "char *com = comando[0]" is invalid as comando[0] is a char (with value 'p') and com is a pointer to char.
The statement "int *x = comando[1]" is invalid, as comando[1] is a char, and x is a pointer to int.
Incidentally, comando[1] is the value of the second character in op. That is a space character which, with on many systems, has the value 32.