Exemple #1
0
int main(){
  int spaces;
  show_n_char(40, '*');
  putchar('\n');
  spaces = (40 - strlen(NAME))/2;
  show_n_char(spaces, SPACE);
  printf("%s\n", NAME);
  spaces = (40 - strlen(ADDRESS))/2;
  show_n_char(spaces, SPACE);
  printf("%s\n", ADDRESS);
  spaces = (40 - strlen(PLACE))/2;
  show_n_char(spaces, SPACE);
  printf("%s\n", PLACE);
  show_n_char(40, '*');
  putchar('\n');
  return 0;
}
int main(void)
{
	int spaces;
	
	show_n_char('*', WIDTH);
	putchar('\n');
	show_n_char(SPACE, 12);
	printf("%s\n", NAME);
	
	spaces = (WIDTH - strlen(ADDRESS))/2;
	show_n_char(SPACE, spaces);
	printf("%s\n", ADDRESS);
	
	show_n_char(SPACE, (WIDTH - strlen(PLACE))/2);
	printf("%s\n", PLACE);
	show_n_char('*', WIDTH);
	putchar('\n');
	return 0;
}
Exemple #3
0
int main(void)
{
    int spaces;

    show_n_char('*', WIDTH);   /* using constants as arguments */
    putchar('\n');
    show_n_char(SPACE, 12);    /* using constants as arguments */
    printf("%s\n", NAME);
    spaces = (WIDTH - strlen(ADDRESS)) / 2;
                               /* Let the program calculate    */
                               /* how many spaces to skip      */
    show_n_char(SPACE, spaces);/* use a variable as argument   */
    printf("%s\n", ADDRESS);
    show_n_char(SPACE, (WIDTH - strlen(PLACE)) / 2);
                               /* an expression as argument    */
    printf("%s\n", PLACE);
    show_n_char('*', WIDTH);
    putchar('\n');
  
    return 0;
}