Skip to main content

All Questions

Tagged with
-2 votes
1 answer
155 views

printf output always before scanf, who can give a solution?

Who know the root cause of print order error? How to resolve it? I compiled the following code to assembly: { int a, b; sprint("input number\n"); scan (a); iprint(a); } ...
Zhang Jason's user avatar
0 votes
1 answer
55 views

Printf does not print the correct values after scanf (ex. 5 is printed as 6618624)

I wrote up a simple calculator that utilizes functions. #include<stdio.h> void operation_menu(); int getNumber(int,int); int sum(int,int); int diff(int,int); int mult(int,int); double quot(...
Lapnesnoj's user avatar
0 votes
2 answers
77 views

how scanf handles standard input vs pipelined input

In the following code: #include <cstdio> using namespace std; int N; char x[110]; int main() { scanf("%d\n", &N); while (N--) { scanf("0.%[0-9]...\n", x); printf("...
coder27's user avatar
0 votes
1 answer
67 views

Scanf_s reading wrong input

For this code below (in C) int small_a, small_b; printf("Please input two numbers\n"); scanf_s("%d %d", &small_a, &small_b); printf("%d %d", &small_a, &small_b); ...
Ansh's user avatar
  • 175
2 votes
2 answers
608 views

"Freezing" an input line in console and printing on the lines above it?

I was wondering if there was a way to "freeze" an input line in order to separate input and output from each other in c. For instance, my console output is currently something like this: 1 ...
Colin Fausnaught's user avatar
0 votes
3 answers
86 views

Can anyone explain the output for scanned value of the following program..?

#include<stdio.h> int main() { int i; printf("%d\n", scanf("%d", &i) ); return 0; } If some value is supplied to scanf() the output of the program is still 1. Why ?
Masud Shaik's user avatar
0 votes
3 answers
1k views

C beginner, code not outputting properly

So I am very new to coding and this is the first time I have used scanf and printf to this extent. For my homework assignment we are supposed to create a program that calculates fuel efficiency in mpg ...
Celeste's user avatar
  • 33
-1 votes
1 answer
158 views

Printf with scanf asking for input. Loop error with BST

I have been trying to see why printf does not break the loop after printing the input of the file. The .c file is BST and I am now in the middle of testing whether a tree has been built but can't seem ...
arrowinfedex's user avatar
1 vote
1 answer
168 views

Program does not wait before output [duplicate]

I'm new to C programming, and I am having trouble with the following code. #include <stdio.h> int main(void) { int input_number; int largest_number = 0; char reply; printf("Hello world\...
user3549805's user avatar
1 vote
3 answers
7k views

Scanning an integer using %c and a character using %d: unexpected results

I am unable to give a proper reason for the following code's output. Can anybody help me. int main() { int i; char ch; scanf("%c",&i); scanf("%d",&ch); printf("%d\n%c",i,ch); ...
abhishekiiit's user avatar
38 votes
2 answers
52k views

C/C++ printf() before scanf() issue

I'm using Eclipse to code in C/C++ and I'm struggling with what might be something pretty easy. In my code below I use printf() and after scanf(). Althougth printf is written before scanf() the output ...
quapka's user avatar
  • 2,939