#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;
class link
{
struct employee
{
int x;
employee *next;
}
void insert()
{
employee *temp;
temp=new employee;
employee *first;
first=new employee;
if(first=NULL)
{
employee *tmep;
temp=new employee;
temp=first;
cin>>first->x;
first->next=NULL;
}
else
{
temp=first;
first=temp;
cin>>temp->x;
temp->next=NULL;
}
}
}
void main()
{
int y;
do
{
cout<<endl;
cout<<"Select one of the following"<<endl;
cout<<"1- Insert "<<endl;
cout<<"2- exit "<<endl;
cin>>y;
switch(y)
{
case 1:
{
void insert();
break;
};
}
}while(y!=2);
}
hussamo
-3
Newbie Poster
Recommended Answers
Jump to Post1-Use code tags please..
2-
if(first=NULL)
Are you assigning or defining a condition?
I think it should beif(first==NULL)
3-
void main()
in c++ is not advisable,
main()
should return a value.
Please,If this helped,mark this thread …
Jump to PostI have a question. Lines #21, #22 and #23:
employee *first=NULL; first=new employee; if(first==NULL){ //...
If you allocate memory for pointer 'first', is that possible for 'first' to be NULL unless you get some exception?
Yes, but what he is doing is wrong. If you use nothrow
when allocating …
All 5 Replies
tkud
0
Posting Whiz in Training
tkud
0
Posting Whiz in Training
pecet
1
Junior Poster in Training
hussamo
-3
Newbie Poster
mrnutty
761
Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.