Am working on a program where am attempting to do an array creation called block that has the ability of holding three addresses. My array should be able to ask the user for the three required addresses. Am interested in knowing if an enum class is required before the struct and array for the information to be pulled in the array and do the creation of the count and cin for the information address? Am actually unable to understand this. Below is what am able to do so far:
#include <iostream>
#include <string>
#include <array>
struct Block
{
int streetNumber;
std::string street;
std::string city;
std::string state;
int zipcode;
};
int main()
{
std::array<Block, 5> address{ };
{
Block.at(0);
Block.at(1);
Block.at(2);
Block.at(3);
Block.at(4);
}
return 0;
)
Here is my new code. The first address works fine, but after the requests for both addresses pops up at the same time and i can't input the information:
#include <iostream>
#include <string>
#include <array>
struct Address
{
int streetNumber{};
std::string street{};
std::string city{};
std::string state{};
int zipcode{};
};
int main()
{
std::array<Address, 5> address{ };
{
std::cout << "Enter your primary address: \n";
std::cin >> address.at(0).streetNumber >> address.at(1).street >> address.at(2).city >> address.at(3).state >> address.at(4).zipcode;
std::cout << "Enter your secondary address: \n";
std::cin>> address.at(0).streetNumber >> address.at(1).street >> address.at(2).city >> address.at(3).state >> address.at(4).zipcode;
std::cout << "Enter an alternative address: \n";
std::cin>> address.at(0).streetNumber >> address.at(1).street >> address.at(2).city >> address.at(3).state >> address.at(4).zipcode;
}
return 0;
}
https://www.theengineeringprojects.com/2019/11/introduction-to-interface-in-c-sharp.html