Solved

printf()

Posted on 2000-04-18
2
445 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

773 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