G'day
This is my second post, also i am new to C++ programming so if i make a mistake or something please correct me ;P.
Today i started this program that converts a persons name to code:
I need help with making an array of the code (cCode[]) by going through cLetters[] and getting each char. I tryed using For statements but i cant get it right.Code:#include <iostream> using namespace std; int main() { // Database char cLetters[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; char cEncryption[] = {'9', 'x', 'j', '4', 't', '5', 'p', 'y', 'c', '3', 'v', 'b', '2', 'e', 'n', 'w', 'o', 'm', 'i', '1', 'r', '1', '7', 'k', 'u', '8'}; // Input users name char cMiddleInitial[1]; char cFirstname[13]; char cLastname[13]; cout << "Enter Firstname: "; cin >> cFirstname; cout << "Enter Middlename Initial: "; cin >> cMiddleInitial; cout << "Enter Lastname: "; cin >> cLastname; char cCode[27]; // Converts name to code int i; int a; for(i = 0; i < 26; i++) { // firstname for(a = 0; a < 13; a++) { if(cLetter[i] == cFirstname[a]) { cCode[] = cEncryption[i]; } } } // Output cout << "Fullname: " << cFirstname << " " << cMiddleInitial << ". " << cLastname << endl; cout << "Code: " << cCode << endl; system("Pause"); return 0; }
Cheer in advance.



LinkBack URL
About LinkBacks


