P
pembed2012
I am sure that I am missing something but I cannot get the following
code to work. It doesn't even make it to my test printf statement
before I get a segmentation fault. Does anyone have any ideas why I
can't get this to run?
void
srtn (int atm[10], int ctm[10])
{
int rng = 0;
int qu[15];
int wt[11];
int tarnd[11];
int i, j;
printf ("This is a test");
for(i = 0; i < 11; i++)
{
wt = 0;
tarnd = 0;
}
qu[0] = 0;
qu[1] = -1;
int size = 1;
i = 0;
while(qu != -1)
{
ctm[qu]--;
rng++;
for(j = i + 1; qu[j] != -1; j++)
wt[qu[j]]++;
for(j = 0; j < 10; j++)
if(atm[j] != -1)
if(atm[j] <= rng)
{
qu[size] = j;
qu[size + 1] = -1;
size++;
}
tarnd[qu]++;
if(ctm[qu] == 0);
atm[qu] = -1;
for(j = 0; j < size; j++)
if(atm[qu[j]] != -1)
if(ctm[qu[j]] < ctm[qu])
i = j;
}
for(i = 0; i < 10; i++)
tarnd += wt;
for(i = 0; i < 10; i++)
{
wt[10] += wt;
tarnd[10] += tarnd;
}
wt[10] = wt[10] / 10;
tarnd[10] = tarnd[10] / 10;
print_report (wt, tarnd);
}
code to work. It doesn't even make it to my test printf statement
before I get a segmentation fault. Does anyone have any ideas why I
can't get this to run?
void
srtn (int atm[10], int ctm[10])
{
int rng = 0;
int qu[15];
int wt[11];
int tarnd[11];
int i, j;
printf ("This is a test");
for(i = 0; i < 11; i++)
{
wt = 0;
tarnd = 0;
}
qu[0] = 0;
qu[1] = -1;
int size = 1;
i = 0;
while(qu != -1)
{
ctm[qu]--;
rng++;
for(j = i + 1; qu[j] != -1; j++)
wt[qu[j]]++;
for(j = 0; j < 10; j++)
if(atm[j] != -1)
if(atm[j] <= rng)
{
qu[size] = j;
qu[size + 1] = -1;
size++;
}
tarnd[qu]++;
if(ctm[qu] == 0);
atm[qu] = -1;
for(j = 0; j < size; j++)
if(atm[qu[j]] != -1)
if(ctm[qu[j]] < ctm[qu])
i = j;
}
for(i = 0; i < 10; i++)
tarnd += wt;
for(i = 0; i < 10; i++)
{
wt[10] += wt;
tarnd[10] += tarnd;
}
wt[10] = wt[10] / 10;
tarnd[10] = tarnd[10] / 10;
print_report (wt, tarnd);
}