The fputs() needs the name of the string and a pointer to where you want to display the text. String output is done with the fputs() and printf() functions. The standard printf function is used for printing or displaying Strings in C on an output device. stdin means to read from the standard input which is the keyboard.Ĭ String Output: C program to Print a String.Output: Enter your full name: Dennis RitchieĪnother safer alternative to gets() is fgets() function which reads a specified number of characters. It stops reading when a newline is reached (the Enter key is pressed). In order to read a string contains spaces, we use the gets() function. The scanf function will only read Guru99. Suppose we give input as “Guru99 Tutorials” then the scanf function will never read an entire string as a whitespace character occurs between the two names. It will halt the reading process as soon as whitespace, form feed, vertical tab, newline or a carriage return occurs. The problem with the scanf function is that it never reads entire Strings in C. Printf("Enter your first name and age: \n") When we use scanf() to read, we use the “%s” format specifier without using the “
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |