We can use printf and it’s family of functions to print substrings, real nice. Have a look

char* pStars = "***************";
int nStarLength = strlen( pStars );

while( nStarLength )
{
  --nStarLength;
  printf( "%.*s\n", nStarLength, pStars );
}

‘*’ will be replaced by value of nStarLength. Number after ‘.’ specifies length of substring from pStars to be printed.

The output will produce this effect

***********
**********
*********
********
*******
******
*****
****
***
**
*
Share
© 2012 bits and bytes Suffusion theme by Sayontan Sinha