Here's an idea:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( void )
{
char *line = NULL;
int linesize, size, front, back;
printf("Enter the size of the pyramid: ");
if( scanf("%d",&size) != 1 )
{
printf("You suck, go away.\n");
exit( 0 );
}
linesize = size * 2 + 1;
if( (line = malloc( sizeof( char ) * linesize )) == NULL )
{
printf("Your computer sucks, go away.\n");
exit( 0 );
}
memset( line, ' ', linesize );
line[linesize-1] = '\0';
for( front = back = size; size > 0; size--, front--, back++)
{
line[back] = line[front] = '*';
printf("%s\n", line );
}
free( line );
getchar( );
return 0;
}
Don't turn this in for homework please. I figured it's be an amusing work around. Enjoy.
[edit]You don't actually need the 'front' line here. You could just use size.[/edit]
Quzah.