Urgently assist to write a dynamic string array

Hi everyone. I have this college project that is giving a headache (i slept early morning at 4 am).

I want to make a table with infinite rows and 15 columns. The table should hold string elements. Kindly advise how to write a dynamic string array (or generally an excel-like table). I have tried severally but wont do due to differing data-type.

I have written the code below, you may advise where to correct:

#include <iostream>


using namespace std;



int main (){

string **landptr;

cout<<"How many records or new people do you want to enter?";

int new_people;

cin>>new_people;


landptr= new string [new_people][15];

int temp1;



for (int i=0;i<new_people; i++)

{
cout<<"Enter the number of people or records you want to register:"<<i+1;



cin>>temp1;

*(landptr+i) = temp1;


}

cout<<"You have entered the number of records as"<<*(land_transaction+i);endl;

for (int i=0;i< new_people ; i++);

}

delete [] landptr;


};







Last edited on
Anyone here please?

The columns of the table will hold such data as Proprietor name, Land_reference id, Tax agency number, Physical address details of the land, status of the land, category, etc.

Someone give an insight please.
This is C++. Use strings and vectors.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <vector>
#include <string>
#include <iostream>
#include <limits>

using namespace std;

int main()
{

  int number_of_people;
  cout << "How many people?" << endl;
  cin >> number_of_people;
  cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
  vector<string> all_the_people;

  while ( number_of_people > 0)
  {
    string details;
    cout << "Enter details:" << endl;
    getline(cin, details);
    all_the_people.push_back(details);
    number_of_people--;
  }

  for (int i = 0; i < all_the_people.size() ; i++)
  {
    cout << all_the_people.at(i) << endl;
  }
}

Last edited on
Thanks comrade Moschops, your answer was real helpful ! Ok, let me go for the vector and strings. Will come back if i encounter a boulder again !
Topic archived. No new replies allowed.