Solved

printf()

Posted on 2000-04-18
2
440 Views
Last Modified: 2013-12-14

Hi,

What is printf()? If it is a function how it will work for different parameters in c?

bye
basavaraj
0
Comment
Question by:cbasavaraj
2 Comments
 

Accepted Solution

by:
JollyJumper earned 10 total points
ID: 2728095
printf() is a function that prints formatted text to the console. It works like
printf("Hello World for the %d time",5);
%d will be replaced with "5" and the string will be printed to stdout.
for strings try %s and for floats %f
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2728123

int printf(const char *format[, argument, ...]);

It's a function, rather special as it accepts a variable number of arguments, the only required parameter is the format string. This format stringr contains information about the optional arguments. Some examples:

printf("Hello World"); // no extra args, just a plain string

char* hello = "Hello World";
printf("%s", hello);

Now the fomat string contains a format specifyer, %s, which tells the function there is a string as extra argument. You can also mix:

char* world ="World";
printf("Hello %s", world);

There are many, many specifyers and format options, you should check your compilers documentation.

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now