#include <iostream>
#include <vector>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL));
std::vector<std::string> possible_result{"Rock", "Paper", "Scissors"};
std::string selection{};
std::cout << "(R)ock, (P)aper, (S)cissors: ";
while(std::cin >> selection){
if (selection != "R" && selection != "P" && selection != "S"){
std::cout << "I didn't get that, try again.\n";
} else {
std::string election = possible_result[rand() % 3];
std::cout << election << '\n';
}
std::cout << "(R)ock, (P)aper, (S)cissors: ";
}
return 0;
}
I'm trying to do a simple Rock, Paper, Scissors game, however when trying to compile I get:
"error: conversion to ‘std::vectorstd::__cxx11::basic_string<char >::size_type’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Werror=sign-conversion]"
I'm using codeblocks, I have -Wsign-conversion in other compiler options, the program runs fine when I delete that line. I don't understand what the problem is, why does it compile without that line? How could I avoid getting that error?