Will This C++ Program Execute Or Not


  • 30 Jan, 2012

    void main(){char *cptr = 0?2000;long *lptr = 0?2000;cptr++;lptr++;printf(? %x %x?, cptr, lptr);}Will it execute or not?Answer1For Q2: As above, won?t compile because main must return int. Also, 02000 cannot be implicitly converted to a pointer (I assume you meant 02000 and not 0?2000.)Answer2Not Excute.Compile with VC7 results following errors:error C2440: ?initializing? : cannot convert from ?int? to ?char *?error C2440: ?initializing? : cannot convert from ?int? to ?long *?Not Excute if it is C++, but Excute in C.The printout:2001 2004Answer3In C++[$]> g++ point.cpoint.c: In function `int main()?:point.c:4: error: invalid conversion from `int? to `char*?point.c:5: error: invalid conversion from `int? to `long int*?in C????????????[$] etc > gcc point.cpoint.c: In function `main?:point.c:4: warning: initialization makes pointer from integer without a castpoint.c:5: warning: initialization makes pointer from integer without a cast[$] etc > ./a.exe2001 2004

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.