Multiple void functions with a string

Been attempting this for a couple hours now, just can't figure out how to get it done with 3 functions. In the main function i'm asking how many teddybears the customer is ordering, in the next function is the teddybear as a string, and for the third function I need 3 teddybears to show up if I entered the number 3 in the first input or however many I entered in. I don't understand how to get the teddy to show up in the last function, I would appreciate any help. Thanks in advance.
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  #include <iostream>
#include <string>
using namespace std;

void tedFactory();
void orderRequest(int quantity);

int main()
{
	int orderQuantity;
	cout<< "Enter the number of teddybears needed by next week for your customers: ";
	cin >> orderQuantity;
	orderRequest(orderQuantity);
	
	return 0;
}
void tedFactory()
{
		
string one =     "                        ,-~-. _.---._ ,-~-.             \n";
string two =     "                       / .- ,'       `. -. \\           \n";
string three =   "                       \\ ` /`        ' \\' /            \n";
string eyes =    "                        `-/   'a___a`  \\-'             \n";
string nose =    "\n                         |   ,'(_)`.    |               \n";
string four =    "                          \\  ( ._|_. ) /               \n";
string mouth =   "                           \\  `.___,'  /                \n";
string five =    "\n                         .-`._     _,'-.                \n";
string six =     "                       ,'  ,' `---' `.  `.              \n";
string chest =   "                      /   /     :     \\   \\             \n";
string seven =   " \n                    ,'   /      :      \\   `.           \n";
string eight =   "                  ,'     |      :      |      `.         \n";
string nine =    "                 |     ,'|      :      |`.     |        \n";
string ten =     "                 `.__,' .-\\     :     /-. `.__,'        \n";
string eleven =  "                       /   `.   :   ,'   \\              \n";
string twelve =  "                  .""-.,'      `._:_,'      `.,-"".       \n";
string thirteen= "               / ,-. `         ) (         ' ,-. \\     \n";
string fourteen= "              ( (   `.       ,'   `.       ,'   ) )     \n";
string fifteen=  "               \\\\    \\  _,'        `._   /    / /      \n";
string sixteen = "                `.`._,'  /            \\  `._,', '      \n";
string seventeen="                  `.__.-'               `-.__,'         \n";
string teddy = one + two + three + four + five + six + seven + eight + nine + ten + eleven + twelve + thirteen + fourteen + fifteen + sixteen + seventeen ;

}
void orderRequest(int orderQuantity)
{
	
	int i = 0;
		while (i < orderQuantity)
		{
			cout << tedFactory << endl;
			i++;
		}
}
Last edited on
you need parenthesis to call a function cout << tedFactory() << endl;
however, that function has no effect, perhaps you may want to return the string.
I actually have to keep the void there for this assignment, and from what I remember (if I remember correct) I can't use a return with a void function.
Start with this :
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
41
42
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int i;
    string bear_drawing[] = 
    {
        "                        ,-~-. _.---._ ,-~-.             \n",
        "                       / .- ,'       `. -. \\           \n",
        "                       \\ ` /`        ' \\' /            \n",
        "                        `-/   'a___a`  \\-'             \n",
        "                         |    ,'(_)`.    |               \n",
        "                          \\  ( ._|_. ) /               \n",
        "                           \\  `.___,'  /                \n",
        "                         .-`._     _,'-.                \n",
        "                       ,'  ,' `---' `.  `.              \n",
        "                      /   /     :     \\   \\             \n",
        "                     ,'   /      :      \\   `.           \n",
        "                  ,'     |      :      |      `.         \n",
        "                 |     ,'|      :      |`.     |        \n",
        "                 `.__,' .-\\     :     /-. `.__,'        \n",
        "                       /   `.   :   ,'   \\              \n",
        "                  .""-.,'      `._:_,'      `.,-"".       \n",
        "               / ,-. `         ) (         ' ,-. \\     \n",
        "              ( (   `.       ,'   `.       ,'   ) )     \n",
        "               \\\\    \\  _,'        `._   /    / /      \n",
        "                `.`._,'  /            \\  `._,', '      \n",
        "                  `.__.-'               `-.__,'         \n"
    };

    int bear_size = (sizeof(bear_drawing) / sizeof(string));
    
    for(i = 0; i < bear_size; i++)
    {
        cout << bear_drawing[i];
    }
    
    return 0;
}
@Hanaka Thanks for the reply! I tried that out and tried to keep my format with the functions in the exact same order as my original post. But I still cannot get the functions right.
If you must have the return value as void, print in the function rather than in main().
Well, for example :
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
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>

using namespace std;

void drawBear()
{
    int i;
    string bear_drawing[] = 
    {
        "                        ,-~-. _.---._ ,-~-.             \n",
        "                       / .- ,'       `. -. \\           \n",
        "                       \\ ` /`        ' \\' /            \n",
        "                        `-/   'a___a`  \\-'             \n",
        "                         |    ,'(_)`.    |               \n",
        "                          \\  ( ._|_. ) /               \n",
        "                           \\  `.___,'  /                \n",
        "                         .-`._     _,'-.                \n",
        "                       ,'  ,' `---' `.  `.              \n",
        "                      /   /     :     \\   \\             \n",
        "                     ,'   /      :      \\   `.           \n",
        "                  ,'     |      :      |      `.         \n",
        "                 |     ,'|      :      |`.     |        \n",
        "                 `.__,' .-\\     :     /-. `.__,'        \n",
        "                       /   `.   :   ,'   \\              \n",
        "                  .""-.,'      `._:_,'      `.,-"".       \n",
        "               / ,-. `         ) (         ' ,-. \\     \n",
        "              ( (   `.       ,'   `.       ,'   ) )     \n",
        "               \\\\    \\  _,'        `._   /    / /      \n",
        "                `.`._,'  /            \\  `._,', '      \n",
        "                  `.__.-'               `-.__,'         \n"
    };

    int bear_size = (sizeof(bear_drawing) / sizeof(string));
    
    for(i = 0; i < bear_size; i++)
    {
        cout << bear_drawing[i];
    }
}

int main()
{
	int i;
	int orderQuantity;
	cout<< "Enter the number of teddybears needed by next week for your customers : ";
	cin >> orderQuantity;

	for(i = 0; i < orderQuantity; i++) drawBear();

	return 0;
}

http://cpp.sh/6dra5
Last edited on
Topic archived. No new replies allowed.