O'Reilly logo

Objective-C Programming: The Big Nerd Ranch Guide by Mikey Ward, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How do I write and use a function?

Now that you have realized that you need a function, you need to write one. Open main.c in your ClassCertificates project and write a new function named congratulateStudent. This function should go just before main() in the file.

#​i​n​c​l​u​d​e​ ​<​s​t​d​i​o​.​h​>​

v​o​i​d​ ​c​o​n​g​r​a​t​u​l​a​t​e​S​t​u​d​e​n​t​(​c​h​a​r​ ​*​s​t​u​d​e​n​t​,​ ​c​h​a​r​ ​*​c​o​u​r​s​e​,​ ​i​n​t​ ​n​u​m​D​a​y​s​){​
 ​ ​ ​ ​p​r​i​n​t​f​(​"​%​s​ ​h​a​s​ ​d​o​n​e​ ​a​s​ ​m​u​c​h​ ​%​s​ ​P​r​o​g​r​a​m​m​i​n​g​ ​a​s​ ​I​ ​c​o​u​l​d​ ​f​i​t​ ​i​n​t​o​ ​%​d​ ​d​a​y​s​.​\​n​"​,​
 ​ ​ ​ ​ ​ ​ ​ ​ ​s​t​u​d​e​n​t​,​ ​c​o​u​r​s​e​,​ ​n​u​m​D​a​y​s​)​;}​ i​n​t​ ​m​a​i​n​(​i​n​t​ ​a​r​g​c​,​ ​c​o​n​s​t​ ​c​h​a​r​ ​*​ ​a​r​g​v​[​]​)​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required