Solved

printf()

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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 …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

688 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