If a data type of char is 1 byte, then should not a char pointer to it also be 1 byte? Why do I have extra data in my char pointer [8 bytes]?
#include <iostream>
#include <conio.h>
using namespace std;
int main ( );
void ShowCharacter ( char *p_character );
int main ( )
{
char character = '\0', *p_character;
p_character = &character;
int size = sizeof ( p_character );
cout << "Pass a variable 'char character' as a pointer!" << endl;
character = getch ( );
ShowCharacter ( p_character );
cout << "Character (main): " << character << " (size: " << size << ")" << endl;
return ( 0 );
}
void ShowCharacter ( char *p_character )
{
char letter = p_character [ 0 ];
// Data type Array >> sizeof ( p_character ) is 8 bytes, why is it an array and not
// a char?
int size = sizeof ( p_character );
cout << "Character (ShowCharacter): " << letter << " (size: " << size << ")\n";
// change letter to p_character to see what I mean.
return;
}
I am trying to write my first game of tic-tac-toe in C++. Understanding this will help me.