cannot convert int to int *

Status
Not open for further replies.

cheenu02

Junior Member level 3
Joined
Jun 16, 2011
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,500
hi,
the following program is not running and give cannot convert int to int * in main function error
#include<stdio.h>
void main()
{
int *p;
p=0x2000;
++p;
printf("%x",p);
}


please give me a solution
thank you
 



While your intentions are unclear as the purpose of your program, the following two lines are the root of your problem. The first defines "p" as a pointer to an integer, the second assign an value of type integer to the pointer. The pointer to an integer "p" can only contain a valid address, not an integer such as 0x2000.

int *p;
p=0x2000;

If you could explain the goal or purpose of your program, maybe I can advise you of a proper route to your desired outcome.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…