i want to know whether this direct assignment to pointer variable is valid or not.
i compiled the program in dev c++ and it works also but i am little bit confused as a pointer variable definition says that it is a variable which holds the address of another variable so is it safe to initialise pointer variables with some values given from cin directly.
Code:#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
struct stu
{
int size;
char name[10];
}*ptr=NULL;
ptr=new stu;
cin>>ptr->size;
cin>>ptr->name;
cout<<ptr->size<<ptr->name;
getch();
return 0;
}