Hello. I am trying to print the address of some pointers, but I am confused.
When I run the program, it printed the whole thing of the user_entry instead of the address of the first indexed value of user_entry, and the last indexed value of the user_entry instead of the address of the last indexed value. How to change it? Thank you in advance.
Below is part of my program.
int main()
{
bool is_a_Palindrome, go_again;
int maxSize = 80;
char user_entry[80];
void printAddresses(char* user_entry, bool &is_a_Palindrome, int &maxSize)
{
char* front = user_entry;
char* back = (user_entry + strlen(user_entry) - 1);
bool* boolPtr = &is_a_Palindrome;
int* sizePtr = &maxSize;
cout << "The beginningaddress of the c-string is " << front
<< ",\nand theaddress of the last character is " << back << endl;
cout << "The address of the bool is " << boolPtr << endl;
cout << "The address of the cstring size int is " << sizePtr << endl;
}
Sample Dialogue:
Enter a string to test for palindrome:
sdfsdf
The entry is not a palindrome
The beginning address of the c-string is sdfsdf,
and the address of the last character is f
The address of the bool is 0018FD6B
The address of the cstring size int is 0018FD50
Would you like to go again? Y/y for yes, any other char for no.