change number to character

I'm beginner and i need help!! I dont know how to change number in character??? for example 4 --> **** or 6-->******
please help
You can just cout a number.

If you want to convert, say, 6 to '6', there is a simple trick:

1
2
3
4
char digit_to_char( int digit )  // 'digit' must be a value in 0..9
  {
  return '0' + digit;
  }

Hope this helps.
Duoas, I don't think that is what he wants.

std::string has a constructor were you can specify what char and how many the string should consist of.

This code gives you a string consisting of 6 stars std::string(6, '*')
Ah, nice catch! I missed that.

Peter87 +1
Topic archived. No new replies allowed.