Question: Run this in devC and try to explain the results considering properties of signed, unsigned, integer, and byte. char * cp ; int ip[10]; char
Run this in devC and try to explain the results considering properties of signed, unsigned, integer, and byte. char * cp ; int ip[10]; char c0, c1, c2, c3; unsigned char uc0, uc1, uc2, uc3; unsigned int ui; #include#include main () { ip [0 ] = -1; //cp = ip + 0; //if an error, change this line to be cp = (char *) ( ip + 0); c0 = cp[0]; c1 = cp[1]; c2 = cp[2]; c3 = cp[3] ; printf("ip[0] = %d cp[0]=%d cp[1] =%d cp[2]=%d cp[3]=%d ", ip[0], c0, c1, c2, c3); //Explain why do you see -1 in all of these arguments! ui = ip[0]; ip [0 ] = ui << 1; ; ui = ui << 1; ip[4] = ui; //cp = ip + 0; //if an error, change this line to be cp = (char *) ( ip + 0); c0 = cp[0]; c1 = cp[1]; c2 = cp[2]; c3 = cp[3]; printf("ip[0] = %d cp[0]=%d cp[1] =%d cp[2]=%d cp[3]=%d ", ip[0], c0, c1, c2, c3); //Explain why you see -2 in some of the arguments ! //cp = ip + 4; //if an error, change this line to be cp = (char *) ( ip + 4); uc0 = cp[0]; uc1 = cp[1]; uc2 = cp[2]; uc3 = cp[3]; printf("ip[4] = %d uc0=%d uc1=%d uc2=%d uc3=%d ", ip[4], uc0, uc1, uc2, uc3); // Explain why you see -2, 254, 255, and 255 for these arguments! system("PAUSE"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
