Confiscated and confused

O

offers

What does

*++*argv

do? I am going through some confuscated code and this didn't make
sense to me. I couldn't find any references to using pointers with
incrementors. Thanks.
 
M

Michael Mair

What does

*++*argv

do? I am going through some confuscated code and this didn't make
sense to me. I couldn't find any references to using pointers with
incrementors. Thanks.

You should tell us the type of argv.
Usually you use argv as a parameter of main():
int main (int argc, char **argv)
{
....
}
So, I will assume that argv is declared as pointer to a pointer to char.
Well, so what is '*argv'? It is a pointer to char, i.e. it could point
to a string. Let us assume it does. Then '++(*argv)' is increasing the
pointer to the next char. '**argv' would be the first character of the
string '*argv' points to. So, '*(++(*argv))' is the character '*argv'
points to _after_ being increased by one. Example

char *mystring = "Hello, world";
char **argv = &mystring;

Then, printf("%c",*++*argv); would give you 'e'.


Cheers
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,157
Messages
2,570,879
Members
47,413
Latest member
KeiraLight

Latest Threads

Top