14.02.2012, 12:48
Quote:
Do you know what this code prints?
pawn Code:
|
EDIT: Oh, I see you've edited it. Let me see again.
pawn Code:
#include <a_samp>
enum E_EG
{
E_EG_NUM,
E_EG_STR[10] // There was an unneeded comma here, so I removed it
}
main()
{
// Part 1.
new eg[E_EG] = {42, "hi"}; // Assigns 42 to the E_EG_NUM var and "hi" to the E_EG_STR var
printf("1) %s %d", eg[E_EG_STR], sizeof (eg[E_EG_STR])); // Prints the string itself, and the size of the string
printf("2) %s %d", eg[E_EG_STR][0], sizeof (eg[E_EG_STR])); // Prints the string, starting from position 0 and the size
func(eg[E_EG_STR]); // Prints the string, and the current size of the string
printf("3) %d", eg[E_EG:2]); // Prints the ascii value of the second character
printf("4) %d", eg[E_EG_STR + E_EG:1]); // Prints the same as above
printf("5) %d", _:E_EG_STR); // No idea what this is though
// Part 2.
new eg2[10] = "hi"; // Creates a new char and assigns the value "hi" to it
printf("6) %s %d", eg2[0], sizeof (eg2[])); // Does exactly what 2) does, but it gets the current size of the variable
func(eg2[0]); // Does exactly what the previous F) does, but assigns the string to be gotten from a chosen position
// Part 3.
new eg3[10][E_EG]; // No idea what this does
printf("7) %s", eg3[0][E_EG_STR]); // No idea what this does
func(eg3[0][E_EG_STR]); // No idea what this does
}
func(data[], size = sizeof (data))
{
printf("F) %s %d", data, size);
}