При компиляции скрипта c ++ в VS Code компилятор не выдает ошибок, а компиляция с использованием CodeBlocks дает мало ошибок. - PullRequest
0 голосов
/ 12 ноября 2018

Это код, над которым я работаю:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main() {
    srand(time(0));

    int a = rand() % 6 + 1;
    int b = rand() % 6 + 1;
    int c = rand() % 6 + 1;
    cout << "a: " << a <<" b: " << b <<" c: " << c << endl;

    if(a < b && a < c){
        cout << a << " is the lower" << endl;
    }
    else if(b < c){
        cout << b << " is the lower" << endl;
    }
    else{
        cout << c << " is the lower" << endl;
    }
    return 0;
}

При компиляции с помощью VS CODE программа показывает результат без ошибок.

При попытке запустить код с помощью компилятора CodeBlocks printследующее сообщение:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
C:\****1_2.cpp||In function 'int main()':|
C:\****1_2.cpp|15|error: 'nullptr' was not declared in this scope|
C:\****1_2.cpp|15|error: 'srand' was not declared in this scope|
C:\****1_2.cpp|17|error: 'rand' was not declared in this scope|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
...