From one of the forums i was reading i got the idea of creating this program.Inputs some line of text and prints them as it was traversed from up to down when arranged in a row-column like structure.
Sample Input:-
ABCD
BMNF
Output:-
ABBMCNDF
#include <stdio.h> #include <string.h> #define BYTES 512 void pud(char *p,int o) { if(!*p)return; int len=strlen(p); if(len>o) putchar(*(p+o)); while(*p++); /*points to first character of the next line*/ pud(p,o); } int main() { char str[BYTES]; int i,max=0x0,j=0x0,t,size; size=fread(str,1,BYTES - 0x1,stdin); str[size]='\x00'; for(i=0x0;i<size;i++){ if(str[i]=='\n'){ str[i]='\x00'; /*to make it usable by strlen*/ t=strlen(&str[j]); if(t>max) max=t; j=i + 0x1; } } for(i=0x0;i<max;i++) pud(str,i); return 0x0; }