LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   segmentation error while running (https://www.linuxquestions.org/questions/programming-9/segmentation-error-while-running-316075/)

Varadharajan 04-22-2005 11:22 AM

segmentation error while running
 
Hi thank you for your suggestions,
I post below my code that causes me segmentation error.
Here is my code .
#include<stdio.h>
#include<math.h>

void clrscr(void){
int i;
for(i=0;i<50;i++)
putchar('\n');
}

int main()
{
int R[10],Rtot,Ravg;
int d[10],p1[10],p2[10],p3[10];
int Ief[10],H,LSR[10],DLSR[10],NTPts[10],i;
printf("\n\tEnter values extracted from RTCP packets\n");

for(i=1;i<4;i++){
printf("\n\tExtracted Values for Connection %d\n\t",i);
printf("\n-------------------------------------------\n");
printf("\n %d Connection's NTP Timestamp value:\n",i);
scanf(" %d",&NTPts[i]);
printf("\n LSR value:\n ");
scanf("%d",&LSR[i]);
printf("\n DLSR value:\n ");
scanf("%d",&DLSR[i]);
printf("\n PacketLoss value:\n ");
scanf("%d",Ief[i]);
printf("\n-----------------------------------------------\n");
clrscr();
}/*end for*/

for(i=1;i<4;i++){
d[i]=NTPts[i]-LSR[i]-DLSR[i];/*Delay calculation*/
printf("\n delay-->%d seconds",d[i] );

H=((d[i]-177.3)<1? 0: 1); /*calculation of H*/
printf("\n H-value :%d",H);

p1[i]=0.024*d[i];
printf("\n p1= %d",p1[i]);

p2[i]=0.11*(d[i]-177.3);
printf("\n p2 =%d",p2[i]);

p3[i]=d[i]-177.3;
printf("\n p3 = %d",p3[i]);

/*R-factor Estimation */

R[i]=94.2-p1[i]+ ((p2[i]) * (H * p3[i])) - Ief[i];
R[i]=abs(R[i]);
printf("\n R-factor for %d conexon=%d",i,R[i]);
}
Rtot=R[1]+R[2]+R[3];
printf("Value of Rtot=%d",Rtot);
Ravg=(Rtot/3);
printf("\nRavg=%d",Ravg);

} with regards,
Varadharajan.

aluser 04-22-2005 01:26 PM

Your last scanf is missing a &.

Vookimedlo 04-22-2005 01:26 PM

You have error in this line.

Code:

scanf("%d",Ief[i]);
Correct solution is

Code:

scanf("%d",&Ief[i]);

aluser 04-22-2005 01:28 PM

beatcha : )


All times are GMT -5. The time now is 11:10 PM.