Kindly and urgently correct me in this code

I am late in submitting this college project. The below code should make an excel-like table (a dynamic 2D array) which the user chooses the number of records he wants to create during runtime. Once he enters the number of records, the program generates a screen into which he enters the details of the individual as shown in the column headings of the worksheet. once through with filling the columns in the first row, the program saves the information and goes to the next row to create the information about the next person depending on the number of records the user specified in the beginning.

Kindly peruse and correct me.

#include <iostream>
#include <string>


using namespace std;


int main ()
{

const int cols = 15;
string **landptr;




cout<<"How many new Land records do you want to create ?";

int input;
cin>>input;



landptr = new string *[input];
for (int i = 0; i < input; i++){

landptr[i] = new string [cols];

for (int column =0; column< cols; column ++)
{
cout <<"Enter the relevant information under the following subtitles in this worksheet:\tLR_Unit_Number\nName_of_proprietor\tNational_ID_CardNumber\tAddress_of_the_proprietor\tPIN_number_of_proprietor\tDate_of_Issue_of_titleDeed\tCategory\tType_of_Ownership\nCounty_Located\tDistrict_Located\tDivision_Located\tLocation_Located\tLocation_Located\tSublocation_Located\tVillage_Located"<<endl;


getline(cin, landptr [i][column]);


cout<<"The information you have input is:\n";

cout<<landptr [i][column]<<"\t";

}

}

//now, we have to free up the memory
for(int i=0;i<i;i++)
delete[] landptr [i];

system ("pause");



return 0;



}




Last edited on
Properly format your code so people can actually read it please...
Thanks Austin. I am real waiting here.

help to format the landptr array to look like the 15 columns of a table and this information to every time pop up in the table as headings of the columns

->\tLR_Unit_Number\nName_of_proprietor\tNational_ID_CardNumber\tAddress_of_the_proprietor\tPIN_number_of_proprietor\tDate_of_Issue_of_titleDeed\tCategory\tType_of_Ownership\nCounty_Located\tDistrict_Located\tDivision_Located\tLocation_Located\tLocation_Located\tSublocation_Located\tVillage_Located"<<endl


The user should input one new record (one row) to fill in specific details according to the headings of the 15 columns.

When the row is full, the information should be saved and the cursor jumps to the next row to create a new record and fill the 15 columns of this row.

The landptr array should take strings from keyboard e.g. using the getline () function..

If the 2D vector is the best choice, kindly direct how to implement it to do the above.
So.. i intend these to be column headings:LR_Unit_Number\t
Name_of_proprietor\t
National_ID_CardNumber\t
Address_of_the_proprietor\tPIN_number_of_proprietor\tDate_of_Issue_of_titleDeed\tCategory\tType_of_Ownership\nCounty_Located\tDistrict_Located\tDivision_Located\tLocation_Located\tLocation_Located\tSublocation_Located\tVillage_located.

Those columns should guide the user as to the specific information to input in that field.

Each row represent a new record which consists the 15 columns. The user should only see the infirmation of row / rows he has entered. But an administrator shhould be able to view the whole table just like an excel worksheet.

Lastly., Kindly illustrate how to write all this formatted information using fstream into a text file.

I will real appreciate your views and especially runnable code. I am a learner
Last edited on
Topic archived. No new replies allowed.