help with a function

so im making a slots game for my class and having trouble with my function.
so my code starts with a random number generator then i want to take that number and put it through a function that has a else it statement that will make the number into a string.

so the question is how to input a int/number and out put a string/letter?
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
55
56
57
58
#include <cstdlib>
#include <iostream>
using namespace std;

void clearScreen();
string test1(int test);


int main(int argc, char** argv) {
    string game;
    int chips=100;
    cout<<"Welcome to the online casino"<<endl;
    cout<<"What game would you like to play We have "
        <<"Game 1 and slots"<<endl;
    
    cin>>game;
    clearScreen();
    
    srand (time(0));
    if (game=="slots"){//slots start ------------------------------------------
        int r1L1 = rand()%13;   //R1L1=row 1 line 1
        int r1L2 = rand()%13;   //R1L1=row 1 line 2
        int r1L3 = rand()%13;   //R1L1=row 1 line 3
        string test234;
        r1L1=1;
        test1(r1L1,test234);
        
        cout<<r1L1;
        
        
        
        
    }//slots end---------------------------------------------------------------
    
    
    
    return 0;
}
void clearScreen(){
    int i;
    for(i=0;i<30;i++){
        cout<<endl;
    }
}

// i know this is wrong bc i have a int in a string function
string find(int inNumber,string out){

    if (inNumber==1){
        out=="c";
        
    }
    else{
        out=="try again";
    }
    return out;
}
Last edited on
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
#include <iostream>
#include <string>
#include <ctime>

std::string find(int);

int main(){

	srand(unsigned(time(NULL)));

	std::cout << find(rand() % 3) << std::endl;

	return 0;
}

std::string find(int num){

	std::string output;

	switch (num){
	case 0:
		output = "Case 0";
		break;
	case 1:
		output = "Case 1";
		break;
	default:
		output = "Default Case";
	}

	return output;
}
Topic archived. No new replies allowed.