Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
main()
{
int *y;
int i,p=0;
int a[655];
int k;



printf("thiru\n");

for(i=0;i<655;i++)
{
y[p]=5;
printf(&quot;%d %d\n&quot;,i,y[p]);
p++;
}
}


it is giving segmentation fault error.
please debug it and help me.
 
Change *y to an array:
int y[655];


Hope this helps,
Corey
 
hello friend ,
i am naresh and i tried your problem.For me it is not giving any kind of problem.

bye naresh.

 
The problem is that y is not initialized to anything, it can point absolutely anywhere (probably somewhere outside the memory segment appointed to your program). This means that you are putting stuff into memory that you have not allocated, and possibly memory that doesn't exist. This is most probably the reason for your segfault.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top