![]() |
| ||
| C++ arrays what does the following do? int array[6] = { 5, 3, 4, 17, 22, 19 }; int* ptr = array[0] *ptr = -1; thank you! |
| ||
| Re: C++ arrays 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. |
| ||
| Re: C++ arrays wow thank you! then in addition, what does ptr+= 2 and ptr[1] =9 do? thank you!! |
| ||
| Re: C++ arrays >>then in addition, what does Think about it and post your answer (or guess) |
| ||
| Re: C++ arrays 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! |
| ||
| Re: C++ arrays yes, but in the original array which element is set to 9? |
| ||
| Re: C++ arrays umm.. is it array[1] which is origially 3 set to 9? |
| ||
| Re: C++ arrays nope -- try again ? |
| All times are GMT -4. The time now is 4:55 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC