2021年4月9日星期五

Dereferencing pointers ( Compliler throws errror) [duplicate]

Why is there rutime error in following program?

using namespace std;  #include <iostream>  int main()  {    int *p ;   // uninitialized    char *c; // uninitialized    string *s; // uninitialized    cout << " p = " << p << " " << &p << " using p : "          << *p << endl;    cout << " s = " << s << " using s : " << *s << endl;    cout << " c = " << c << " using c : " << *c << endl;    return 0;  }  

Output of the program is as follows-

 p = 0x40eba9 0x6ffdf8 using p : 264275272   s = 0x1d using s :  

Then program stops. I could not find the reason.

https://stackoverflow.com/questions/67030644/dereferencing-pointers-compliler-throws-errror April 10, 2021 at 11:56AM

没有评论:

发表评论