what does the following do?

    int array[6] = { 5, 3, 4, 17, 22, 19 };

    int* ptr = array[0]
    *ptr = -1;

thank you!

The first line initializes the values of the array.
The second line is a syntax error. It should be int* ptr = &array[0]; The last line sets the value of te first array element to -1.

wow thank you!

then in addition, what does

ptr+= 2
and ptr[1] =9

do?

thank you!!

>>then in addition, what does
Think about it and post your answer (or guess)

okies..

so this is what i thought:

ptr+= 2
increases the pointer by two.. so the ptr will now point to array[2]

and ptr[1] =9

the value of index 1 is equal to 9..

is this correct?

thank you!

yes, but in the original array which element is set to 9?

umm.. is it array[1] which is origially 3 set to 9?

nope -- try again ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.