Find the mistake

There's a mistake in this program and I have to find it, but I dont find it anywhere. Any help please?

#include <iostream>
using namespace std;

int main()
{
	struct A {
		char a;
		float b;
	};

	A *a;

	a=0;
	a->a='a';
	a->b=5.6;

	cout <<a->a << endl;

}
Think what happens on line
a=0;

You never actually make an A struct, only a pointer to one, replace:
a=0;

with

a=new A;
#include <iostream>
using namespace std;

int main()
{
	struct A {
		char a;
		float b;
	};

	A *a;

	a= new A;
	a->a='a';
	a->b=5.6;

	cout <<    << endl;

}



So it's something like this? If I wish to make the cout of a->a, how should I introduce it in the cout line?
It would still be

 
cout << a->a << endl;
Also, remember to delete it after using it...

@ThangDo

It would still be
cout << a->a << endl;


What error did you find here?!
I didn't find any error on that line ? did I overlook something?
a->a is a char, and Im cout-ing this char.

Topic archived. No new replies allowed.