This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

b!=0 why???

#include <reg51.h>

void main()
{
int a[3][4]={{0,1,2,3},{4,5,6,7},{8,9,10,11}};
int (*p)[4];
int b=0; /b=256 why???
int c;
p=a;
b=*(*p+2)+3;
b++;
c=b;
}
#include <reg52.h>
void main(void)
{
unsigned int wer[5]={0,1,2,3,4};
unsigned int b=0; //result:b=256 why????
unsigned cde;
b+=1; //b=257 why????????
b--; //b=256 why????
b++;
}

  • b!=0 why???
    --------------------------------------------------------------------------------
    #include <reg51.h>

    void main()
    {
    int a[3][4]={{0,1,2,3},{4,5,6,7},{8,9,10,11}};
    int (*p)[4];
    int b=0; // b=0
    int c;
    p=a;
    b=*(*p+2)+3;
    b++;
    c=b;
    }
    #include <reg52.h>
    void main(void)
    {
    unsigned int wer[5]={0,1,2,3,4};
    unsigned int b=0; //result:b=0
    unsigned cde;
    b+=1; //b=1
    b--; //b=0
    b++;
    }

    On mine, it works...

    regards

    Dejan