What is the problem with pointers in c?

Plsss help...code(c++) problem(POINTERS)?

  • INCLUDE<IOSTREAM.H> VOID MAIN() { INT ARRAY[]={4,6,10,12}; INT*PTR=ARRAY; FOR(INT I=1;I<=3;I++) { COUT<<*POINTER<<"#" POINTER++; } COUT<<ENDL; FOR(I=1;I<=4;I++) { (*POINTER)*=3; --POINTER; //<---------THIS ONE } FOR(I=1;I<5;I++) COUT<<ARRAY[I-1]<<"@" } COUT<<ENDL; .. .. THE ANS IS COMING OUT TO BE ------> 4#6#10# 12@18@30@36@ <-------I AM HAVING DIFFICULTY IN THIS LINE SINCE IT WAS GIVEN IN THE PROGRAM "--POINTER"...HOW COME IT IS NOT POINTER ++ AGAIN.....SHOULDNT IT BE?? PLS EXPLAIN ME THIS LINE PROPERLY THANX A LOT IN ADVANCE

  • Answer:

    All are upper case. Any how you are taking PTR as the pointer to the array. void main() { int array[]={4,6,10,12}; int *PTR=array; for(int i=0;i<4;i++) {cout<< *PTR<<endl; PTR++; } for(int i=0;i<4;i++) { *(PTR) *=3; --PTR; } for(int i=0;i<4;i++) cout<<array[i]<<endl; return 0; } Do remember that in C/C++ first element index is 0. Not 1.

kvothe at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

All are upper case. Any how you are taking PTR as the pointer to the array. void main() { int array[]={4,6,10,12}; int *PTR=array; for(int i=0;i<4;i++) {cout<< *PTR<<endl; PTR++; } for(int i=0;i<4;i++) { *(PTR) *=3; --PTR; } for(int i=0;i<4;i++) cout<<array[i]<<endl; return 0; } Do remember that in C/C++ first element index is 0. Not 1.

James Bond

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.