Keep that Makefile around since it'll help you spot errors and we'll be adding to it when we need to automate more things.
Many programming languages use the C way of formatting output, so let's try it:
Once you have that, do the usual make ex3 to build it and run it. Make sure you fix all warnings.
This exercise has a whole lot going on in a small amount of code so let's break it down:
The result of doing this is you are handing printf some variables and it is constructing a new string then printing that new string to the terminal.
When you do the whole build you should see something like this:
Pretty soon I'm going to stop telling you to run make and what the build looks like, so please make sure you're getting this right and that it's working.
In the Extra Credit section of each exercise I may have you go find information on your own and figure things out. This is an important part of being a self-sufficient programmer. If you constantly run to ask someone a question before trying to figure it out first then you never learn to solve problems independently. This leads to you never building confidence in your skills and always needing someone else around to do your work.
The way you break this habit is to force yourself to try to answer your own questions first, and to confirm that your answer is right. You do this by trying to break things, experimenting with your possible answer, and doing your own research.
For this exercise I want you to go online and find out all of the printf escape codes and format sequences. Escape codes are \n or \t that let you print a newline or tab (respectively). Format sequences are the %s or %d that let you print a string or a integer. Find all of the ones available, how you can modify them, and what kind of "precisions" and widths you can do.
From now on, these kinds of tasks will be in the Extra Credit and you should do them.
Try a few of these ways to break this program, which may or may not cause it to crash on your computer:
# edit ex3.c to break printf $ make ex3 cc -Wall -g ex3.c -o ex3 ex3.c: In function 'main': ex3.c:8: warning: too few arguments for format ex3.c:5: warning: unused variable 'age' $ ./ex3 I am -919092456 years old. I am 72 inches tall. # edit ex3.c again to fix printf, but don't init age $ make ex3 cc -Wall -g ex3.c -o ex3 ex3.c: In function 'main': ex3.c:8: warning: 'age' is used uninitialized in this function $ ./ex3 I am 0 years old. I am 72 inches tall. $