Hi folks,
I am learning C++ programming.
Below mentioned program giving segmentation fault ONLY WHEN if I declare 'struct s a;'
ABOVE 'struct s *b;'.
Can anybody tell me the reason?
#include<iostream>
using namespace std;
struct s
{
int m;
};
int main()
{
struct s a; // if I put this below 'struct s *b; then i wont get segmentation fault
struct s *b;
b->m = 5;
cout<<"m="<<b->m<<endl;
return 0;
}
output:
./a.out
Segmentation fault