Safest Driving Area

Problem: Write a program that determines which of 5 geographic regions within a major city (north, south, east, west, central) had the fewest reported traffic accidents last year. it should also have this function called by main.

int getNumAccidents()is passed the name of a region. it asks the user fro the number of accidents in that region during the last year and returns it. It should be called once for each city region.

this is my code.

#include <iostream>
using namespace std;
int getNumAccidents(string &);

int main()
{
string north;
string south;
string east;
string west;
string central;

cout << "Enter the number of traffic accidents reported\nlast ear in each of the following city regions." << endl;

getNumAccidents(north);
getNumAccidents(south);
getNumAccidents(east);
getNumAccidents(west);
getNumAccidents(central);

return 0;
}

int getNumAccidents(string &region)
{
double number;
cout << "How many accidents were reported in " << &region << "?" << endl;
cin >> number;

return 0;
}

Here is my problem. When the program asks the question 'how many accidents were reported in _____ region', instead of showing me the name of the region, it shows me the memory address of the string variables (north, south, etc.) I don't know how to show the names of the regions themselves. How do I make it so that I see the names of the regions and not the memory addresses?
it shows me the memory address of the string variables


The solution is to quit asking it to show the memory address of the string variables.

cout << "How many accidents were reported in " << region << "?\n";
Topic archived. No new replies allowed.