Name: Anonymous 2013-04-03 9:26
The way I am trying to go about it is to find the lowest value in the array, concatenate it onto the end of an output string, then change that value to null so it won't be compared in the next loop iteration. I have had little success.
So far nothing is printed.
char input[40], output[40], lowest, buffer[100];
int i=0, j=0, position;
printf("Enter a string (1-40 characters): ");
fgets(input, 40, stdin);
/*converts to lower case and deletes special characters*/
for(j=0;j<40;j++)
{
if(input[j]<91 && input[j]>64)
input[j]+=32;
if(input[j]<97 || input[j]>122)
input[j]='*';
}
j=0;
for(j=0;j<40;j++)
{
lowest=input[j];
position=j;
for(i=0;i<40;i++)
{
if(lowest!=NULL);
{
if(input[i] < lowest)
{
position=i;
lowest=input[i];
}
}
}
if(lowest!=NULL);
{
sprintf(buffer, "%c", cvalue);
strcat(output, buffer);
memset(buffer, 0, sizeof(buffer));
input[cposition]='*';
cvalue=NULL;
}
}
printf("Output: %s", output);So far nothing is printed.