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 gkittelson 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.
 
You store a value in an unallocated array/pointer.
The y pointer is not allocated so y[p] is not a valid address.

Look my answer in thread: thread205-301176


Maybe what you want to do is:
Code:
for(i=0;i<655;i++)
{
Code:
a
Code:
[p]=5;
printf(&quot;%d %d\n&quot;,i,
Code:
a
Code:
[p]);
p++;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top