**

Hi all,
I would like to understand the following loop, used in a remote control program (interaction between two entities using pipes) in thermodynamic modeling:
1
2
char** command;
for(command=script;**command;command++)


The part of this loop's body that I don't get is the **command, could anyone help me with this?
Thank you very much,

Skyboarder
It is a check wthether the char pointed by *command is equal to zero.

Let assume you have an array of pointers in which the last alement of the array poimts to an empty string literal, that is *a[2] == '\0' Then you can print out all string literals until the empty literal will not encountered.

1
2
3
4
5
6
7
8
char *a[] = { "first", "second", "" };

char **command;

for ( command = a; **command; ++command ) 
{
   std::cout << *command << std::endl;
}


*command - is an address of a string literal in the example above. While **comand is the first character of the string literal.
Last edited on
Thank you very much for this simple explanation!

Skyboarder
Topic archived. No new replies allowed.