Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

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
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,273
Trophy points
1,413
Location
Southwest, USA
Activity points
62,490
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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top