Wednesday, 2 November 2011

Text Alignment Programme - Central Alignment

//Programme for central alignment of text
/*                          Compiler Used: Bordland Turbo 3.0
                             OS Used         : Windows XP
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
int c_align(char b[]);
void main()
{
    char t1[40],t2[40],t3[40],t4[40];
    clrscr();
    printf("\nTAG1: ");
    gets(t1);
    printf("\nTAG2: ");
    gets(t2);
    printf("\nTAG3: ");
    gets(t3);
    printf("\nTAG4: ");
    gets(t4);
    clrscr();
    gotoxy(c_align(t1),2);printf("%s",t1);
    gotoxy(c_align(t2),3);printf("%s",t2);
    gotoxy(c_align(t3),4);printf("%s",t3);
    gotoxy(c_align(t4),5);printf("%s",t4);
    getch();
}
int c_align(char b[])
{
    int t_space=80,len=0;
    len=strlen(b);
    t_space=t_space-len;
    t_space=t_space/2;
    return t_space;
}

No comments :

Post a Comment