string init error??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void print_frame(string, int);

 // function to print a given message inside an asterisk frame with the given padding
/**/
void print_frame(string msg, int pad) {
	 // define the number of rows and cols based on the padding value given
	/**/
	const string::size_type rows   = pad * 2 + 3;
	const string::size_type cols    = msg.size() + pad * 2 + 2;
	
	 // calculate how much white space is needed and define a buffer
	/**/
	const string::size_type s_size = msg.size() + pad * 2;
	const string s_buf(s_size, " ");

	for (int r = 0; r != rows; ++r) {
		string::size_type c = 0;

		while (c != cols) {
			 // is it time to print the message?
			/**/
			if (r == pad + 1 && c == pad + 1) {
				cout << msg;
				c += msg.size();
			}

			 // check to see if we are on the border
			/**/
			if (r == 0 || r == rows - 1 || c == 0 || c == cols -1) {
				cout << "*";
				++c;
			} else {
				cout << s_buf;
				c += s_size;
			}
		}

		cout << endl;
	}
}


Can someone please help me figure out why I'm getting an error C2664 for initializing the s_buf var it would be much appreciated.

Thanks in advance. :)
const string s_buf(s_size, " "); is not a valid std::string constructor.
For std::string constructors - see here:
http://www.cplusplus.com/reference/string/string/string/
Topic archived. No new replies allowed.