0

I have a question about that I would greatly appreciate if someone with knowledge could answer. In C, is it valid to print a character times a variable?

For example (spaces and stories are both integers):

printf(" " * spaces);

or

printf("#" * stories);

In case anyone is confused, in the first printf, I was trying print out multiple spaces. I've included the CS50 library but I still keep getting errors about these lines. Do they need to be written a different way or is this method simply invalid?

1

Nope, can't do it that way.

If you want to print multiple copies of a char based on a var's value, think for loop.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .