I am suppose to
"Create a program to read an array of characters from the keyboard terminated by EOF. Count the number of characters that are entered. The characters should be stored into an array of integers. Display the array of characters as characters. Call shellsort (pp 62) to sort the array and display the sorted array."
Here is the thing I almost have it all done but I am trying to print out the letters for each character it stores in the array and then sort the array and display it. The problem is that I just tested the while loop without the shellsort program and it will not show the letters I store in the array.
Am I just not thinking my logic is correct or am I naming a variable wrong?
Also am I using the wrong names for the variables in the shellsort? I am getting a "error: expected expression before âintâ" and a " error: too few arguments to function âshellsortâ"
Here is my code I hope someone can point me in the right direction im so confused.
Code:
#include <stdio.h>
void shellsort(int v[], int n);
main()
{
char str[100]="abcdefgh";
int num[100];
int v[100];
int i, c, n;
i=0;
printf("%s\n", str);
while ((c = getchar()) != EOF)
{
num[i++] = c;
for (i=c; i != EOF; i++)
printf("%c", num[i]);
}
shellsort(int v[i], int n);
printf("%c", v[i]);
}
void shellsort(int v[], int n)
{
int gap, i, j, temp;
for (gap = n/2; gap > 0; gap /= 2)
for (i = gap; i < n; i++)
for (j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap)
{
temp = v[j];
v[j] = v[j+gap];
v[j+gap] = temp;
}
}