Working through more compiler warnings...
This commit is contained in:
parent
97043b1831
commit
e5fffdeaf1
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
CFLAGS=-Wall -Wextra -pedantic-errors -g -DNDEBUG
|
CFLAGS=-Wall -Wextra -pedantic -g -DNDEBUG
|
||||||
|
|
||||||
EXERCISES = $(patsubst %.c,%,$(shell ls ex*.c | egrep -v "ex(19|22)"))
|
EXERCISES = $(patsubst %.c,%,$(shell ls ex*.c | egrep -v "ex(19|22)"))
|
||||||
|
|
||||||
|
2
ex15.c
2
ex15.c
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
char **arg = argv;
|
char **arg = argv;
|
||||||
for(i = 0; i < argc; i++) {
|
for(i = 0; i < argc; i++) {
|
||||||
printf("argument %d is '%s' (address = %p)\n", i, *arg, arg);
|
printf("argument %d is '%s' (address = %p)\n", i, *arg, (void *)arg);
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
ex16.c
6
ex16.c
@ -15,7 +15,7 @@ struct Person *Person_create(char *name, int age, int height, int weight)
|
|||||||
struct Person *who = malloc(sizeof(struct Person));
|
struct Person *who = malloc(sizeof(struct Person));
|
||||||
assert(who != NULL);
|
assert(who != NULL);
|
||||||
|
|
||||||
who->name = strdup(name);
|
who->name = strdup((char *)name);
|
||||||
who->age = age;
|
who->age = age;
|
||||||
who->height = height;
|
who->height = height;
|
||||||
who->weight = weight;
|
who->weight = weight;
|
||||||
@ -49,10 +49,10 @@ int main(int argc, char *argv[])
|
|||||||
"Frank Blank", 20, 72, 180);
|
"Frank Blank", 20, 72, 180);
|
||||||
|
|
||||||
// print them out and where they are in memory
|
// print them out and where they are in memory
|
||||||
printf("Joe is at memory location %p:\n", joe);
|
printf("Joe is at memory location %p:\n", (void *)joe);
|
||||||
Person_print(joe);
|
Person_print(joe);
|
||||||
|
|
||||||
printf("Frank is at memory location %p:\n", frank);
|
printf("Frank is at memory location %p:\n", (void *)frank);
|
||||||
Person_print(frank);
|
Person_print(frank);
|
||||||
|
|
||||||
// make everyone age 20 years and print them again
|
// make everyone age 20 years and print them again
|
||||||
|
2
ex18.c
2
ex18.c
@ -81,7 +81,7 @@ void test_sorting(int *numbers, int count, compare_cb cmp)
|
|||||||
|
|
||||||
free(sorted);
|
free(sorted);
|
||||||
|
|
||||||
unsigned char *data = (unsigned char *)cmp;
|
unsigned char *data = (unsigned char *)&cmp;
|
||||||
|
|
||||||
for(i = 0; i < 25; i++) {
|
for(i = 0; i < 25; i++) {
|
||||||
printf("%0x:", data[i]);
|
printf("%0x:", data[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user