Пример #1
0
int main(int argc, char *argv[]) {
    // create two arrays we care about
    int ages[] = {23, 43, 12, 89, 2};
    char *names[] = {"Alan", "Frank", "Mary", "John", "Lisa"};
    int count = sizeof(ages) / sizeof(int);

    print_indexing(names, ages, count);
    print_divider();
    print_pointers(names, ages, count);
    print_divider();
    print_pointers_as_arrays(names, ages, count);
    print_divider();
    print_stupid_complex(names, ages, count);
    print_divider();
    print_addresses(names, ages, count);

    return 0;
}
Пример #2
0
int main(int argc, char *argv[]) {
	// create two arrays we care about
	int ages[] = {23, 43, 12, 89, 2};
	char *names[] = {
		"Alan", "Frank",
		"Mary", "John", "Lisa"
	};
	int count = 5;

	print_indexing("%s has %d years alive.\n", count, names, ages);
	printf("---\n");

	print_pointing("%s has %d years alive.\n", count, names, ages);
	printf("---\n");

	print_pointing_again("%s is %d years old again.\n", count, names, ages);
	printf("---\n");

	print_stupid_complex_way("%s is %d years old again.\n", count, names, ages);
	printf("---\n");

	return 0;
}