-
Parallel Arrays
over 8 years ago
-
over 8 years ago
Hi, I suggest you to do it using vector but if you want to use array then please have a look on the below approach.
#include <iostream> #define LIMIT 100
using namespace std; int main() { string first_name[LIMIT]; string last_name[LIMIT]; string str1; string str2; int j = 0; char sentinelCharater = 'n'; char sentinelInput; cout << "Enter 'y' to continue else 'n' to stop taking inputs : "; cin >> sentinelInput; while(sentinelInput != sentinelCharater) { cin >> str1 >> str2; first_name[j] = str1; last_name[j] = str2; j++; cout << "Enter 'y' to continue else 'n' to stop taking inputs : "; cin >> sentinelInput; } cout << "\n\nResults" << endl; for (int i = 0; i < j; i++) cout << first_name[i] << "." << last_name[i] << "@" << "stallion.edu" << endl; return 0; }
-
over 8 years ago
Thank you, so much !
-
2 Answer(s)