i m getting a runtime error and the program skips the first attribut i.e name,and gives a runtime error at the second one.compiler gives some warning about gets".\Assignment 3_Question 4.cpp(118) : warning C4996: 'gets': This function or variable may be unsafe. Consider using gets_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
"
my code is :
char *addcustomer(char **p,int n)
{
cout << " ------- Add Customer Record --------" << endl << endl;
for(int i=0;i<n;i++)
{
cout << "Please Enter Customer Name: " ;
cin.getline(p[i],20,'\n');
cout << endl;
cout << "Please Enter Customer NIC Number: " << endl;
gets(p[i+1]);
//cout << p[i+1]<< endl;
cout << "Please Enter Customer Telephone: Number " << endl;
gets(p[i+2]);
//cout << p[i+2]<< endl;
cout << "Please Enter Customer Room Number: " << endl;
gets(p[i+3]);
//cout << p[i+3]<< endl;
cout << "Please Enter Customer Entry Date and Time: " << endl;
gets(p[i+4]);
//cout << p[i+4]<< endl;
cout << "Please Enter Customer Exit Date and Time: " << endl;
gets(p[i+5]);
//cout << p[i+5]<< endl;
cout << "Please Enter Customer Payments: " << endl;
gets(p[i+6]);
//cout << p[i+6]<< endl;
cout << "Please Enter Customer Status: " << endl;
gets(p[i+7]);
//cout << p[i+7]<< endl;
}
return 0;
}
int _tmain()
{
int choice,n;
cout << "Please Enter the number of records you want to Enter: " << endl;
cin>>n;
char **p=new char*[n];
cin.ignore();
for(int i=0;i<n;i++)
{
p[i]=new char[20];
}
cin.ignore();
.
.
.
.
addcustomer(p,n);
.
.
.
return 0;
}
thanks in advance!