What is the program doing ? cplusplus

  c++
#include <iostream>
using namespace std;

void updateValue(int *p){
    *p = 610 % 255;
}

int main(){
    char ch = 'A';
    updateValue((int*)&ch);
    cout << ch;
}

Dear Friends why output is d ?
please explain updateValue((int*)&ch) line means?

Source: Windows Questions C++

One Reply to “What is the program doing ? cplusplus”

  • First the ASCII value of A is 65 and when we called the update value function we can see that it is a int type pointer, so after evaluating *p = 610%255 you got *p = 100 which is the value of d in ASCII chart.

LEAVE A COMMENT