This is a discussion on Confused with Result within the C and C++ forums, part of the Programming Talk category; I have my C program as below: void main() { int *s,*t; s=(int*)2000; t=(int*)3000; printf("...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have my C program as below:
void main() { int *s,*t; s=(int*)2000; t=(int*)3000; printf("%d",(t-s)); } I thought the output would be 1000. But the output was 500.I was confused with why I got this output. Someone explain me on this. |
|
|||
|
The result 500 is perfectly right. This is because t and s are declared as integer pointer variable and integer variables occupy 2 bytes generally and so the difference of 1000 space is equal to 500 integer spaces apart. This is the reason for getting output as 500.
|
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| expected and actual result | anjaligupta_28 | Software Testing | 5 | 09-12-2007 12:08 PM |
| Result of Program | ashlee | C and C++ | 1 | 05-10-2007 09:22 AM |
| query result | b_s_meena | SQL Server 2005 Tutorials | 4 | 02-16-2007 03:44 AM |
| techmahindra fresher result | yash_mave | Career Advice | 0 | 06-01-2006 08:14 AM |
| TechMahindra Fresher Drive Result | yash_mave | Suggestions & Feedback | 0 | 05-27-2006 06:48 AM |