This program seemed to run fine the first time, but now it gives me a core dumped program aborted error which I do not understand why.
Here is the code:
Code:
#include <stdio.h>
int main ()
{
int a[25], i, j, m, t;
printf ("\nEnter 25 numbers \n");
for (i=0; i<=24; i++)
{
scanf ("%d", &a[i]);
}
for (i=0; i<=24; i++)
{
for (j=0; j<=24-i; j++)
{
if (a[j] > a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
printf ("\n The sort list is \n");
for (i=0; i<=24; i++)
printf ("%d", a[i]);
}
In order to run the program, I created a data file contained 1 - 25 on each line and I would feed it to my executable as such:
./buble < data
I have attached the data file to the question. I tried to used gdb, but am not sure how to use redirection within gdb.