[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

printf()

Posted on 2000-04-18
2
Medium Priority
?
455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
JollyJumper earned 30 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

649 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