LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-22-2005, 11:22 AM   #1
Varadharajan
LQ Newbie
 
Registered: Apr 2005
Posts: 3

Rep: Reputation: 0
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.
 
Old 04-22-2005, 01:26 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
Your last scanf is missing a &.
 
Old 04-22-2005, 01:26 PM   #3
Vookimedlo
Member
 
Registered: Jul 2004
Location: Czech Republic - Roudnice nad Labem
Distribution: Debian
Posts: 253

Rep: Reputation: 33
You have error in this line.

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

Code:
scanf("%d",&Ief[i]);
 
Old 04-22-2005, 01:28 PM   #4
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
beatcha : )
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault when running john jayrusso Linux - Software 3 11-30-2005 07:08 PM
segmentation fault while running ymessenger felnlily Linux - Software 3 02-03-2005 03:01 AM
Segmentation fault while running RPM KaruppuSwamy.T Linux - General 5 12-03-2004 05:56 AM
Segmentation fault when running ls kd7trn Linux - Software 2 09-10-2004 04:54 PM
segmentation fault running UT linoob Linux - Software 6 09-11-2003 08:33 PM


All times are GMT -5. The time now is 03:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration