C: For Beginners - Putting on the Puts()
(Page 4 of 4 )
Another way to print strings to the screen is using the puts() function. You can use puts() when you do not plan on using placeholders:
#include <stdio.h>
int main (void)
{
puts("Hello, pretty lady!");
return 0;
}
This prints out:
Hello, pretty lady!
Note that puts() automatically places a new line in your code, whether you like it or not. What a jerk. There is also a function called fputs, which works in a similar manner, but it is a little beyond the scope of this article, and to be honest, I would typically just stick with the printf() function.
Printing Is Fun Until Someone Loses Your Eyes
Printing is all fun and good and is probably the most used function in all of C, but wouldn't you like to do more than blabber at the user all day? I mean, I like to do that, but I am a writer. You, yer just a programmer. You let your programs interact with humans so you don't have to go out in the sunlight and get all burned up by that big yellow ball of heat someone told you was called "the sun."
Haha! I tricked you! You thought I was going to teach you how to do more than print, but I was merely Jedi mind tricking you to come back and read my next article, where I will discuss getting input from the user and working with variables to store information.
So come back. What else have you got to do?
Till then...
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |