Questions tagged as 'scanf'

1
answer

How to limit the decimal places of the scanf of a double variable?

The exercise asks that the readings of double variables be limited to only one decimal place each. I tried to put "%.1lf" in scanf , just like we used in printf , but it did not work. How could I solve this? int ma...
asked by 12.08.2016 / 05:55
5
answers

Keyboard buffer cleaning after scanf

I'm having problems with the scanf(); function. When reading two or more values, subsequent values are not read. I've already tried: __fpurge(stdin); After doing the readings, but in this case, I need to give an enter after each...
asked by 15.03.2014 / 18:25
1
answer

cin vs scanf, which one is faster?

In competitive programming, it is common for many programmers to use scanf() and printf() in C ++ code instead of using cin and cout . And I've even seen problems that result in a Time Limit Exceeded (TLE) when us...
asked by 01.05.2016 / 22:47
2
answers

What is sscanf () and sprintf () used for?

What is sscanf() and sprintf() ?     
asked by 13.10.2018 / 22:07
1
answer

Parameters of the scanf function

While studying the scanf function with a little more depth, I had a question about the arguments I put before% when reading a string, that is scanf("argumentos...%s",minhastring) , in the following codes I add a space and the ' J 'b...
asked by 27.06.2016 / 03:15
2
answers

Why does the order of these scanf's make a difference in the result?

The program adds x1 and x2 and places the result in x1 . It does not work if x1 is read before x2 . But if you reverse this order, it works. #include <stdio.h> #include <stdlib.h> unsigned char x1,...
asked by 31.03.2015 / 18:02
2
answers

String of characters within the scanf. Why and how does scanf works ("Day% d", & day);

Problem I was making a code that would be to read a string and then an integer value: int dia, h, m, s; char dp; //Dois pontos. scanf("Dia %d",&dia); //Inicio do evento. ... I thought about creating a string for the us...
asked by 13.10.2014 / 13:00
3
answers

Program does not meet expected flow reading and printing entry

#include <stdio.h> #include <stdlib.h> int main() { int num1, num2, num3; printf("Digite o numero A e numero B para saber o resto da divisao resultante da divisao entre eles:\n"); printf("NumeroA: "); scanf("%...
asked by 05.11.2017 / 22:50
1
answer

Scanf is not stopping in repetition

I have a loop while that will only end when the value 0 (zero) is entered. I have a variable that will receive a command option. Within the loop I have a switch case where: 0) exits the program (returns to while and ends);...
asked by 25.01.2016 / 13:38
2
answers

Function scanf with variable amount of parameters, how to implement?

I have a text file (txt) that contains the following values: 12 90 These two values I keep and my variables a and b , that is a is equal 12 and b is equal 90 , and I'm using scanf() function to...
asked by 02.05.2016 / 20:42