int main() { Person* alice = malloc(sizeof(Person)); Person* bob = malloc(sizeof(Person)); int generator = 3; int modulus = 17; //Generate secret number they only know alice->secret_number = 15; bob->secret_number = 13; //Generate public number and exchange to the other person bob->shared_public_number = GeneratePublicNumber(alice, generator, modulus); alice->shared_public_number = GeneratePublicNumber(bob, generator, modulus); //Calculate the Secret CalcSecret(alice, modulus); CalcSecret(bob, modulus); //Draw Information printf("Alice\n"); PrintPerson(alice); printf("Bob\n"); PrintPerson(bob); return 0; }
int main() { person persona[MAX_PERSON]; int num = 0, choice = 1; DisplayMenu(); while (choice != 0) { cout << endl << "Enter command: "; cin >> choice; while (cin.fail()) { cout << "Invalid input, enter number 0-7:"; cin.clear(); cin.ignore(256, '\n'); cin >> choice; } if (choice == 0) { cout << "Goodbye" << endl; return 0; } if (choice == 1) DisplayMenu(); if (choice == 2) AddPerson(persona, &num); if (choice == 3) PrintPerson(persona, num); if (choice == 4) PrintAllPersons(persona, num); if (choice == 5) DeletePerson(persona, &num); if (choice == 6) ExportToFile(persona, num); if (choice == 7) ImportFromFile(persona, &num); } return 0; }