473,378 Members | 1,543 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

what is the difference between printf and scanf?

what is the difference between printf and scanf?
Feb 21 '13 #1
3 11523
donbock
2,426 Expert 2GB
printf is a means to send information out of your program to a user (output).

scanf is a means to pull information from a user into your program (input).
Feb 21 '13 #2
HI ! printf will print the data you ask from the program to print, like for example if you have an int a, and you have put the value 1 to it, you can write in the program printf("The value of a is: %d\n",a); %d will print the integer after the comma, and the \n will move the cursor a line down after the printing, so you'll have printed:
The value of a is: 1

scanf reads data. For example you can have scanf(“%d”,&k); if you have an int k, before that, and it will read the value of k that the user will give and put it in k.
Feb 21 '13 #3
scanf is for taking input from the user. the user input is interpreted as per the format specifier(%c, %d, %u etc) specified. It requires the address of the variable in which the value is to be stored. This is given by &(variable name)

printf is used for displaying data to the user. The output is formatted as per the format specifier used (%c, %d, %u etc).
Feb 22 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: diadia | last post by:
string s = "hello"; const char *p = s.begin(); cout << p << endl; // print hello s = ""; char *p2= s.begin(); cout << p2 << endl; // print hello why?????
11
by: J Wang | last post by:
dear, I debug the program recently as follows. #include <sys/stat.h> int main(int argc, char *argv) { struct stat buf;
6
by: Dawn Minnis | last post by:
Hi (running Win xp and developing using Miracle C. Running applications in windows command prompt) I'm new to the group so be gentle with me. I am currently writing a C program to perform...
6
by: dmoisset | last post by:
Hi, I'm looking for a standard definition about what should {printf ("%f", x)} do when x is INFINITY... I've found that in ISO C99 the output should be "inf" or "infinity", but I was wondering if...
18
by: Martin Jørgensen | last post by:
Hi, Today I got a really strange problem... I've made myself a data-file and I read in data from that file.... When I read something like this line: 03 04 05, 00 04 01, 05 03 07, 08 03...
2
by: gkrishgkm | last post by:
how to use printf/scanf inside printf
2
by: ledzepfan32 | last post by:
i have a question: what does printf do? i have seen it a lot, but cannot find a clear description of what it does. in my learn c++ in 21 days book, it states that it will not teach it in the book....
0
by: RupeshDeenadayalan | last post by:
Is there any difference between a boot loader and a boot strapper.It would be better if any one can tell what operations does a general bootloader,boot strapper,BSP,Driver does???
5
by: bhushanbagul | last post by:
Hi All Please let me know exactly what difference i and g makes in oracle version i.e. when we say oracle 10g or oracle 11i Thanks Bhushan
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.