The difference between Codecademy and Visual Studio Code

Hi! I made a code for rock_paper_scissors_lizard_spock.cpp and it runs well in codecademy’s terminal, but it doesn’t work in VSC. I think the reason is UTF or sth. Does anyone know how can I make no error also in VSC?

#include <iostream>
#include <time.h>

int main() {
  srand(time(NULL));
  int computer = rand() % 5 + 1;
  int user = 0;
  
std::cout << "=================================\n";
std::cout << "rock paper scissors lizard spock!\n";
std::cout << "=================================\n";

std::cout << "1) ✊\n";
std::cout << "2) ✋\n";
std::cout << "3) ✌️\n";
std::cout << "4) 🦎\n";
std::cout << "5) 🖖\n";
  
std::cout << "shoot!" ;
std::cin >> user;
  
  switch(computer){
    case 1:
      std::cout << "Computer : ✊\n";
        switch(user){
          case 1:
            std::cout << "Tie!\n";
            break;
          case 2:
            std::cout << "You Win!\n";
            break;
          case 3:
            std::cout << "You Lose...\n";
            break;
          case 4:
            std::cout << "You Lose...\n";
            break;
          case 5:
            std::cout << "You Win!\n";
            break;
          default:
            std::cout << "Unknown error\n";
            break;
        }
        break;
    case 2:
      std::cout << "Computer : ✋\n";
        switch(user){
          case 1:
            std::cout << "You Lose...\n";
            break;
          case 2:
            std::cout << "Tie!\n";
            break;
          case 3:
            std::cout << "You Win!\n";
            break;
          case 4:
            std::cout << "You Win!\n";
            break;
          case 5:
            std::cout << "You Lose...\n";
            break;
          default:
            std::cout << "Unknown error\n";
            break;
        }
        break;
    case 3:
      std::cout << "Computer : ✌️\n";
        switch(user){
          case 1:
            std::cout << "You Win!\n";
            break;
          case 2:
            std::cout << "You Lose...\n";
            break;
          case 3:
            std::cout << "Tie!\n";
            break;
          case 4:
            std::cout << "You Lose...\n";
            break;
          case 5:
            std::cout << "You Win!\n";
            break;
          default:
            std::cout << "Unknown error\n";
            break;
        }
        break;
    case 4:
      std::cout << "Computer : 🦎\n";
        switch(user){
          case 1:
            std::cout << "You Lose...\n";
            break;
          case 2:
            std::cout << "You Win!\n";
            break;
          case 3:
            std::cout << "You Win!\n";
            break;
          case 4:
            std::cout << "Tie!\n";
            break;
          case 5:
            std::cout << "You Lose...\n";
            break;
          default:
            std::cout << "Unknown error\n";
            break;
        }
        break;
    case 5:
      std::cout << "Computer : 🖖\n";
        switch(user){
          case 1:
            std::cout << "You Win!\n";
            break;
          case 2:
            std::cout << "You Lose...\n";
            break;
          case 3:
            std::cout << "You Lose...\n";
            break;
          case 4:
            std::cout << "You Win!\n";
            break;
          case 5:
            std::cout << "Tie!\n";
            break;
          default:
            std::cout << "Unknown error\n";
            break;
        }
        break;
    default:
      std::cout << "Unknown error\n";
      break;
    }
}

Like this, it doesn’t work.

1 Like

Hey asiadecoder, I think you probably have to include the library or <stdlib.h> to use pseudo random numbers.

Hi asiadecoder, I think you have to include the proper library to generate pseudorandom numbers.

Try to include:

#include or #include <stdlib.h>

codecademy is a website
vscode is an editor
neither is a compiler
your screenshot shows you successfully compiling

1 Like

Then what’s the reason output is not a proper words?
That’s what I’m curious the most.

If you mean “why am I getting 1) ?? in the console”, I’d suggest it’s because your terminal doesn’t understand emoji…