|
-
July 13th, 2012, 08:24 AM
#1
char* p="array"; it is valid but int *po=&20; is illegal. but why, how etc?
tell me if i m wrong somewhere!!
int *pint=&10;
here pointer is pointing to an integer which is not even declared so it is not written in memory, that's why when we does such declaration it comes out as an error at compile time or run time.
But what about this
char *pchar="array";
here "array" returns it's address(much similar to &10 as in previous case here array byself returns it's address) but this one is legal and works fine. But why? There was a similar declaration in the previous case but that failed, can i not use the same logics to say it is wrong as i said in previous case?. If yes then why it works? if no then where am i getting it wrong? If you are in doesn't know category then open your book and tell me what is it. :P
thanks!
Last edited by vkash; July 13th, 2012 at 08:57 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|