Thursday, April 13, 2023

Adventures with chatGPT

Recently I came across a surprising result with a short C++ code and asked GPT4 for guidance, it performed well:

Me: On visual studio 2022, when building in debug x86, why is the variable "a" printed as strange values like 4294967296 in the following c++ code: 

#include <stdio.h>
int main() {
    for (unsigned long long i = 0; i < 5; i++) {
        unsigned long long a = i;
        printf("i = %u, a = %llu\n", i, a);
    }
    getchar();
    return 0;
}