Can you write a C program to print the String in the center of the Screen...
Heres a little demonstration of that.
/*
This program will move the string to the center of the screen.
Center in this context is a relative thing. So I have taken my screen size as 80
and did the program. The user has to change according to his size of the screen.
*/
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
void mystring(char* s);
int main()
{
char name[10];
mystring("ENTER YOUR NAME\n");
mystring("");
scanf("%s",&name);
mystring(name);
mystring("\n");
system("pause");
}
void mystring(char* s)
{
int screen_size = 80;
int l=strlen(s);
int pos=(int)((screen_size-l)/2);
for(int i=0;i < pos;i++ )
printf(" ");
printf("%s",s);
}
A Collection Of Weird and Interesting C Programs by Balaji
Tuesday, July 3, 2007
Interesting C Program -3
Posted by
Balaji V
at
12:07 AM
Labels: INTERESTING C PROGRAMS
Subscribe to:
Post Comments (Atom)







0 comments:
Post a Comment