I know my question is not specific but let me explain it this code
char name[5][30];
for (int i = 0; i < 5; i++)
cin >> name[i];
for (int i = 0; i < 5; i++)
cout<<name[i];
in the example above i created an array of characters where you can input five words each with 30 bit length. and it works just fine but when i try to use a pointer like so when you don't know how many words you are about to input. I get an error in line 5 saying a value of type int cant be asigned to char and i understand the error but how how to get pass this problem?
int n;
cout << "Number of names" << endl;
cin >> n;
int *name;
name = new char[n][30];
for (int i = 0; i < 5; i++){
cin >> *name;
name++;
}
for (int i = 0; i < 5; i++){
cout << *name;
name++;
}
nameto automatically point to yournew-ed array?std::vector<int>andstd::string.std::vector(variable-length array) andstd::string?nameanint*in the second example? IIn what way does it make sense for a name to be anint?std::vectorandstd::stringfirst, and about pointers andnewforty seventh.