Following is the method of dynamic memory allocation I learnt ,
int *p = new int;
i.e.
pointer-variable = new data-type;
However in another programme of linked list, I saw a structure delaration
struct node
{
int info;
struct node *next;
}
And declaration of its instance was like
struct node *temp, *s;
temp = new(struct node);
I mean it should be wrong because according to the syntax it should not include struct , it should be like this
node *temp, *s;
temp = new node ;
Where am I wrong,can anyone please guide me ?
This is the source code ,Refer to code at line no. 125 & 126.