-2

When I run the code in replit I get the following output 1024, 512,0,0,0 but when I run it in VS Code I get 2,2,0,0,0. Is there something wrong with my VS Code C++ configuration.

#include <iostream>
#include <cctype>

using namespace std;
int main(){
string my_string;
cout << "Enter a string: " ;
getline(cin,my_string);
cout << isalpha(my_string[0]) << endl;
cout << islower(my_string[0]) << endl;
cout << isupper(my_string[0]) << endl;
cout << isdigit(my_string[0]) << endl;
cout << isspace(my_string[0]) << endl;
return 0;
}
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Pygatti
  • 1
  • 1
  • 1
    What do you give as input? Anyhow these are C functions. 0=false, !0 = true. I.e. depending on the platform it can be any value other than zero. You need to `static_cast` the output to `bool`. And print using `boolalpha` or so. – JHBonarius Feb 07 '22 at 18:44

1 Answers1

3

When those functions return a positive value, it can be any positive value. There are no guarantees about it being a particular positive value, nor that the value will always be the same positive value.

Is there something wrong with my VS Code C++ configuration.

No; this is normal.

eerorika
  • 232,697
  • 12
  • 197
  • 326