Before you can do this pyramid, you have to know how many rows the pyramid will require. For each row, you need one more space. (I used *'s here for easy counting).
You were on the right track with using strlen().
Code:
#include <stdio.h>
#include <string.h>
int main() {
int i, j, k, row, maxCol, maxRow;
char *letters = {"abcdefghijklmnopqrstuvwxy"};
maxCol = strlen(letters);
/*this was the toughest part. You can't print up the pyramid right,
unless you know how many rows it will contain, before you start
*/
for(i = 1, j = 1; j < maxCol; i++)
j = (2*j + 2) ;
//if you use postfix increment (i++), you need to subtract 1
//to get the goal index you want, frequently.
maxRow = i-1;
j = k = 0;
printf("\n\n\n");
for(row = 0; k < maxCol; row++) { //handles the rows
for(i = j; i < maxRow; i++) {
printf("%c", '*'); //the star's
}
for(i = 0; i <= row+j; k++, i++) { //the letters
printf("%c", *letters+k);
}
putchar('\n');
j++;
}
printf("\n\n\t\t\t press enter when ready");
i = getchar();
return 0;
}
/*
****a
***bcd
**efghi
*jklmnop
qrstuvwxy
*/