iam an amatuer who is trying to get into the C programming but I have many doubts please help me. If scan is function than what value does scanf returns and similarly about printf what is the output of this statement
main()
int i;
printf(""%d",scanf("%d",scanf("%d",&i));
}
4 4287
Hi neotan,
Welcome to TSDN. I am sure you will find a wealth of answers from the experts in the various forums.
I will move this question to the c(++) forum for you. In future, you can access the forums directly by selecting from the different tabs on the blue bar near the top of your screen.
I hope the c/c++ experts can be of assistance!
iam an amatuer who is trying to get into the C programming but I have many doubts please help me. If scan is function than what value does scanf returns and similarly about printf what is the output of this statement
main()
int i;
printf(""%d",scanf("%d",scanf("%d",&i));
}
Bookmark this link. It's a nice reference for your C and/or C++ development.
scanf returns the number of items that were succesfully scanned and printf returns
the number of characters that were printed.
Your code example most likely produces a core dump because its second, third
etc. (if applicable) arguments are supposed to be addresses where the scan
results should be stored.
kind regards,
Jos
In order to test the return values, try this code: -
#include <stdio.h>
-
-
int main (void)
-
{
-
int i;
-
printf("Enter an integer value: ");
-
-
int j = scanf("%d", &i);
-
int k = printf("Items Scanned: %d", j); // Outputs "1"
-
-
printf("\nItems Printed: %d\n", k); // Outputs "16" (Total character outputs from last printf)
-
-
return 0;
-
}
-
neotan-
Please also have a look at our Posting Guidelines, including those that request you use good thread titles, and code tags.
I've changed this thread title, please let me know if you don't think it adequately describes your issue.
Thanks, and welcome!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David |
last post by:
Could someone help me turn this program into a program that accepts
files(database) as an input and writes to a file as method of saving
the database information?
#include <stdio.h>
#define n...
|
by: Tom Lam lemontea |
last post by:
Hi all,
This is my very first post here, I've seriously tried some programming
on C, and shown below is my very first program(So you can expect it to
be very messy) that I wrote after I've learned...
|
by: nimmi_srivastav |
last post by:
Below you will see an example of a nested conditional expression that
this colleague of mine loves. He claims that it is more efficient that
a multi-level if-else-if structure. Moreover, our...
|
by: Gregc. |
last post by:
Hi
Sorry to bother you gusy with such a basic question, but I am working
on a conversion program. I've got most of it down, but I am having
trouble with the output:
*Dollar Conversion...
|
by: chiefs |
last post by:
I'm a beginner in C++!!
#1-Dont know how to loop end when int q(entered); int q is a very large # when ran: printf("\n%i#of Questions\n", q);
#2-is the line "how many questions Right"?...
|
by: aljaber |
last post by:
hi,
i am facing a problem with my program output
here is the program
/*********************************************\
* CD Database *
* ...
|
by: chevon1920 |
last post by:
Hi, I just have a question for anyone who can help. I am trying to write a program that will print to a file. The program has a while loop so that when I run it, it should print to the file each time...
|
by: S. |
last post by:
Hi all,
I have the requirement that I must pass-by-reference to my function
addStudent() and getAge() functions where my getAge() function is
within the addStudent() function. I am able to...
|
by: subramanian100in |
last post by:
Consider the following program named as x.c
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
unsigned int u;
char str;
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |