I am trying to create a game like a simple PapersPlease but when my program outputs a random name from my array it outputs a garbage value (�) and I'm not sure on how to fix this issue:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int random_number;
string RandomName;
string names[12] = {"Lucas","Rendeev","J2Trappy","D2Savvy","James","Daniel","Abraham","Shaggy","Luke","Harry","Rick","Morty"};
int main(){
srand(time(NULL));
random_number = rand() % 12;
RandomName = names[random_number - 1];
cout << "Name: "<<RandomName<<"\n";
}
Sample output:
Name: �
�t
Aucun commentaire:
Enregistrer un commentaire