test problem

I have a problem with an excercise for c++ test. It goes like this:

What will be the type and value of x if you run the program with initialization values "pierw" and "drugi"

int main(int argc, char **argv) {
*argv++;
x=*argv;
}

Answers:

a) i
b) p
c) erw
d) pierw
e) drugi


Hope someone will be willing to help me. I dont even know how this program even runs.
Last edited on
Lol, trick question. Just try to compile it and you'll see why. Or did you accidently a word?
well i tried and debugger wants me to specify type of x. I assume just according to logic ;p its a) but dont really know why
I think x is supposed to be a char. In which case the answer would be [redacted].
Answer isn't as important as the others questions i have:

From what i assume (i'm a total noob) function takes "pierw" as second argument and it's type is pointer to a char pointer. Char is an array and pointer points to the first element so its "p". Then it's moved +1 so it's "i". Trying to understand this. But i don't get it if its "i" couse second pointer only gets a memory address of first one in array and dont really knows that second poiter points to array?? And i have no idea what type x would be and WHY. If someone can help me understand this i will be gratefull or direct me where i can look for an answer.
I think you're supposed to deduce what 'x' is from the code. IE: it's defined somewhere above main, but what is it defined as?

And the answer is definitely one of the 5 given.
I'd take a look at what char** argv is actually pointing to. Remember what argv means.
Topic archived. No new replies allowed.