Error
I'm not sure what this error means, would someone be able to explain?
1 2 3 4 5 6 7 8 9 10 11
|
void userBrowse(userProfile user[], int currentMaxPersons)
{
clearScreen(100);
std::cout << "First Name" << '\t' << "Last Name" << '\t' << "Address" << '\t' << "Number" << std::endl << std::endl;
for (int i = 0; i < currentMaxPersons; i++)
{
std::cout << user[i].firstName << '\t' << user[i].lastName << '\t' << user[i].address << '\t' << user.number << std::endl; // ERROR IS HERE
}
std::cout << std::endl << "Please press 'ENTER' when you are finished";
std::cin.ignore();
}
|
|35|error: request for member 'number' in 'user', which is of pointer type 'userProfile*' (maybe you meant to use '->' ?)|
|
Full code(WIP)
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#include <iostream>
void clearScreen(int maxAmount);
struct userProfile
{
int userNumber;
std::string firstName;
std::string lastName;
std::string address;
std::string number;
};
void userImport(userProfile user[], int currentMaxPersons)
{
user[currentMaxPersons].userNumber = currentMaxPersons;
std::cout << "Please enter in the persons first name: ";
std::cin >> user[currentMaxPersons].firstName;
std::cout << "Please enter in the persons last name: ";
std::cin >> user[currentMaxPersons].lastName;
std::cout << "Please enter in the persons current address: ";
std::getline(std::cin, user[currentMaxPersons].address);
std::cout << "Please enter in the persons current phone number: ";
std::getline(std::cin, user[currentMaxPersons].number);
return;
}
void userBrowse(userProfile user[], int currentMaxPersons)
{
clearScreen(100);
std::cout << "First Name" << '\t' << "Last Name" << '\t' << "Address" << '\t' << "Number" << std::endl << std::endl;
for (int i = 0; i < currentMaxPersons; i++)
{
std::cout << user[i].firstName << '\t' << user[i].lastName << '\t' << user[i].address << '\t' << user.number << std::endl;
}
std::cout << std::endl << "Please press 'ENTER' when you are finished";
std::cin.ignore();
}
void userSearch(userProfile user[], int currentMaxPersons)
{
return;
}
void clearScreen(int maxAmount)
{
for (int i = 0; i < maxAmount; i++)
{
std::cout << std::endl;
}
}
int menuOptions()
{
clearScreen(100);
int userInputMenuChoice;
std::cout << "Welcome to the main menu" << std::endl << std::endl;
std::cout << "1. Import a user" << std::endl;
std::cout << "2. Browse the user database" << std::endl;
std::cout << "3. Search for a user" << std::endl;
std::cout << "4. Exit" << std::endl;
std::cout << "Please choose and option ranging from 1 to 4: ";
std::cin >> userInputMenuChoice;
return userInputMenuChoice;
}
int main()
{
int currentMaxPersons = 0;
userProfile user[999];
bool runProgram = true;
while (runProgram)
{
switch(menuOptions())
{
case 1:
userImport(user, currentMaxPersons);
currentMaxPersons++;
break;
case 2:
userBrowse(user, currentMaxPersons);
break;
case 3:
userSearch(user, currentMaxPersons);
break;
case 4:
runProgram = false;
break;
default:
std::cout << "Please enter a value between 1 and 4";
break;
}
}
}
|
Topic archived. No new replies allowed.