#include <stdio.h>

int main(int argc, char **argv)
{
	int i;

	char myarray[4];
	short secondarray[6];
	char *thirdarray[12];

	printf("Uninitialised arrays:");

	for (i = 0; i < 4; ++i)
	{
		printf("myarray[%d] = '%c' or %d\n", i, myarray[i], myarray[i]);
	}

	for (i = 0; i < 6; ++i)
	{
		printf("secondarray[%d] = %d\n", i, secondarray[i]);
	}

	for (i = 0; i < 12; ++i)
	{
		printf("thirdarray[%d] = %p\n", i, thirdarray[i]);
	}

	// Loop until newline is read
	printf("\n\nPress ENTER to continue...");

	while (getchar() != '\n') // Loop until we get the newline character from the input
	;                         // A quick and dirty loop - probably should also check for EOF!

	printf("\n\n"); // Add some blank lines before the next part

	{
		short shortarray[2] = {4, 1};
		char chararray[3] = {'o', 'n', 'e'};

		long longarray[] = {100000, 5, 543};
		char chararray2[] = {'C', '-', 'S', 't', 'r', 'i', 'n', 'g', '\0'};

		/* sizeof() is an operator which returns the size (in terms of the size of a char) of
		 * its operand. You can use it on many different things, e.g. arrays (size of array),
		 * pointers (size of the pointer), basic types, etc. If we have the full array
		 * declaration, i.e. the name with the [] on it, then we can determine the number of
		 * elements from the size of the array divided by the size of an element. */

		 for (i = 0; i < (sizeof(shortarray) / sizeof(short)); ++i)
		 {
			 printf("shortarray[%d] = %d\n", i, shortarray[i]);
		 }

		 for (i = 0; i < (sizeof(chararray) / sizeof(char)); ++i)
		 {
		 	 printf("chararray[%d] = '%c' or %d\n", i, chararray[i], chararray[i]);
		 }

		 for (i = 0; i < (sizeof(longarray) / sizeof(long)); ++i)
		 {
		 	 printf("longarray[%ld] = %d\n", i, longarray[i]);
		 }

		 for (i = 0; i < (sizeof(chararray2) / sizeof(char)); ++i)
		 {
		 	 printf("chararray2[%d] = '%c' or %d\n", i, chararray2[i], chararray2[i]);
		 }
	}

	 return 0;
}