Hi everyone!
Can any one tell what wrong with this code, I mean when i insert the printf function within the for loop (the i loop) it lists me all the steps correclty. But why it doesn't display the string sorted in one shot using the last printf..that what i want to do..
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 24 int main(){ char x[SIZE]; int i, j, t = 0; gets(x); for (i=1; i<SIZE; i++){ t=x[i]; for (j = i; j>0 && x[j-1]>t ; j--){ x[j]=x[j-1]; } x[j]=t; } printf("%s\n",x); system("PAUSE"); return(0); }