char arrays, pointers, etc, could use help badly
Code:
#include <iostream.h>
using namespace std;
void displayDay(char *ptr);
void displayDayAddress(char *ptr);
int main(){
char *days[] = {"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"}; //array of char pointers
int selectedDay;
char *ptr; //character pointer
cout << "OUTPUT FOR PROBLEM #6a and #6b: " << endl;
cout << "What day is it today? (1 - 7): ";
cin >> selectedDay;
ptr = days[selectedDay - 1]; //store address of the given array element in ptr
displayDay(ptr);
cout << "\n\nOUTPUT FOR PROBLEM #6c: " << endl;
cout << "This day's address begins at: ";
displayDayAddress(ptr);
return 0;
} //end int main
void displayDay(char *ptr){
cout << "Today's day is " << ptr;
} //end void displayDay
void displayDayAddress(char *ptr){
cout << &ptr;
}
For some reason I can't do what I want to do. What I want to do:
-Send into a function that large *char array of months, and an int
-In that function, the user will input a number into this int
-That day is called from the function. For instance, entering 2 will display Monday
-Then I need to make another function that outputs the address of the first character of the day inputted.
However, I can't get this to work right! I can't pass the values correctly so the majority of it is in main!! I could really use some assistance