#include <iostream>#include <Stdlib.h>#include <stdio.h>void CopyString (char *s, char *t){ while ((*s = *t) != '\0') { s++; t++; }}using namespace std;int main(){ int start_i = 2; char *name = new char[start_i]; char *mother_name = new char[start_i]; char *father_name = new char[start_i]; char *date = new char[start_i]; char *gender = new char[start_i]; int age; char *personal_information = new char[start_i]; int i = 0; char c; char *s2 = new char [start_i]; cout<<"Name : "; while ((c = getchar())!= '\n') { if (i > start_i-2) { *(name+i+1) = '\0'; CopyString (s2,name); ++start_i; name = new char[start_i]; CopyString(name, s2); s2 = new char[start_i]; } *(name+i) = c; i++; } *(name+i)='\0'; start_i = 2; i = 0; s2 = new char [start_i]; system("cls"); cout<<"Mother's name : "; while ((c = getchar())!= '\n') { if (i > start_i-2) { *(mother_name+i+1) = '\0'; CopyString (s2,mother_name); ++start_i; mother_name = new char[start_i]; CopyString(mother_name, s2); s2 = new char[start_i]; } *(mother_name+i) = c; i++; } *(mother_name+i)='\0'; start_i = 2; i = 0; s2 = new char [start_i]; system("cls"); cout<<"Father's name : "; while ((c = getchar())!= '\n') { if (i > start_i-2) { *(father_name+i+1) = '\0'; CopyString (s2,father_name); ++start_i; father_name = new char[start_i]; CopyString(father_name, s2); s2 = new char[start_i]; } *(father_name + i) = c; i++; } *(father_name+i)='\0'; start_i = 2; i = 0; s2 = new char [start_i]; system("cls"); cout<<"Personal information : "; while ((c = getchar())!= '\n') { if (i > start_i-2) { *(personal_information+i+1) = '\0'; CopyString (s2,personal_information); ++start_i; personal_information = new char[start_i]; CopyString(personal_information, s2); s2 = new char[start_i]; } *(personal_information + i) = c; i++; } *(personal_information+i)='\0'; start_i = 2; i = 0; s2 = new char [start_i]; system("cls"); cout<<"Date of birth : "; while ((c = getchar())!= '\n') { if (i > start_i-2) { *(date+i+1) = '\0'; CopyString (s2,date); ++start_i; date = new char[start_i]; CopyString(date, s2); s2 = new char[start_i]; } *(date + i) = c; i++; } *(date+i)='\0'; start_i = 2; i = 0; s2 = new char [start_i]; system("cls"); cout<<"Age : "; cin>>age; cin.clear(); cin.ignore(cin.rdbuf()->in_avail()); system("cls"); cout<<"Gender : "; while ((c = getchar())!= '\n') { if (i > start_i-2) { *(gender+i+1) = '\0'; CopyString (s2,gender); ++start_i; gender = new char[start_i]; CopyString(gender, s2); s2 = new char[start_i]; } *(gender + i) = c; i++; } *(gender+i)='\0'; start_i = 2; i = 0; s2 = new char [start_i]; system("cls"); cout<<"Name : "<<&name[0]<<endl;; cout<<"Mother's name : "<<&mother_name[0]<<endl; cout<<"Father's name : "<<&father_name[0]<<endl; cout<<"Personal information : "<<&personal_information[0]<<endl; cout<<"Date of birth : "<<&date[0]<<endl; cout<<"Age : "<<age<<endl; cout<<"Gender : "<<&gender[0]<<endl; system("pause"); return 0;}
Comments