Hey guys am a newbie in c programming actually..I have a char array and am trying to keep the elements in an order. I have done it scuccefully but when i print the elements of the array an extra character ÿ
happens in my code.
My code
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
char values[4] = "mmfa";
int cmpfunc (const void * a, const void * b)
{
return(*(char*)a - *(char*)b);
}
int main()
{
int n;
qsort(values, 5, sizeof(char), cmpfunc);
printf("\nAfter sorting the list is: \n");
for( n = 0 ; n < 5; n++ )
{
printf("%c ", values[n]);
}
return(0);
}
When i print this i get the result ÿ a f m m
.I need to remove the ÿ
..I have tried it by escaping the aray with \
but it didnt worked out.So how would i able to remove the ascii code
from the result.
Thanx for the help