Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   using pointer (http://www.go4expert.com/forums/using-pointer-t7885/)

answerme 17Dec2007 14:01

using pointer
want to print the sum of M to N numbers ,using pointer .Where am i getting wrong

        int m,n;
        int *p1,*p2,sum=0,*p;
        printf("Enter the m");
        printf("Enter the n");

kv.santosh 17Dec2007 14:52

Re: using pointer
1. " *p1=&m; *p2=&n;" This is wrong. If you want to make pointer p1 to point to integer m, then it should be "p1 = &m".
2. Where did u initilize pointer p. it should be hoding some junk value!!!!!
3. I did not understand your concept of using a while loop for sumation. Moreover in this exercise your not getting any benifit of using pointers!!!!! If you really want to play arround with pointers, do something more complicated...a simple link list might be.

answerme 17Dec2007 15:27

Re: using pointer
thanks i made some stupid mistakes

All times are GMT +5.5. The time now is 19:22.