Questions tagged as 'scanf'

1
answer

C print name with scanf

I have the following code, the problem is that it returns string2 as '(null)'. How do I solve it? and why does this happen? #include <stdio.h> int main() { char *string; char *string2; printf("Primeiro nome: "); scanf("%...
asked by 24.09.2014 / 11:39
1
answer

How to make the program stop in each printf?

I would like to make the user type printf() at a time, being "Name, RG and Email" but as soon as I type the name, it executes everything else and ends the program, how do I stop it in the next printf() for the user? int main () {...
asked by 22.10.2018 / 00:02
1
answer

Char reading failed with scanf ("% c") [closed]

Check this code to register two random arrays and then add, multiply ... I want to put an option that every operation made the user has the option to exit the program, without going back to the initial menu, putting him to choose between 1 and 2...
asked by 13.10.2015 / 21:57
2
answers

How do I validate input into c?

My problem is that I have to force the user to enter a single integer value, if he puts anything else (characters or decimals) I should have him type again. I already tried to validate scanf but it did not work. So I did a function to do...
asked by 26.10.2016 / 00:30
1
answer

Problem with scanf on% d receiving a keyboard letter

I have a problem, I am reading a int %d by scanf , but if the user types a letter the program enters loop . void chama_menu_switch(Fila **f, int n){ char confi; int i,y,x,a,z; double r; a = 0; int b; for (i = 0; z != 11; i++) {...
asked by 10.06.2016 / 02:53
0
answers

Segmentation fault (core dumped) in array data scanf

This next piece of error code, does not read the user data to allocate in the 5x2 array, I can not find the problem int linha=0, coluna=0; int matriz[5][2]; for(linha=0;linha < 5; linha++){ for(coluna=0;coluna < 2; col...
asked by 08.09.2018 / 02:43
1
answer

Problem with printf and scanf - My code does not print the correct information

I have this code here that is not reading the characters correctly when printing the user-populated data on the screen. Can you help me? // Question 1) Make an algorithm that reads a user's name, rg, age, gender, address, phone, and cell. //...
asked by 19.03.2018 / 23:27
0
answers

Using printf and scanf in Eclipse and Netbeans - Language C

Good evening. I have the program below that asks the user to insert two numbers and then present them. In Code Blocks is working correctly, however when I run in Eclipse or Netbeans, the system waits for the numbers to be entered without the pre...
asked by 25.02.2018 / 02:04
1
answer

Receiving a user's data and displaying this data at the end

I want to receive the data of a user and at the end when I run the program I want to show them, but I think that the variable is not so, because the program jumps from name to age directly, and address and does not leave, what I intend is to cre...
asked by 07.11.2017 / 13:14
2
answers

How to show all elements of an array declared in a struct in C?

In this code: #include <stdio.h> #include <stdlib.h> struct cadastro { char nome[50]; int idade; char rua[50]; int numero; }; int main() { struct cadastro c[4]; //Array[4] de estruturas for(int i=0; i<4; i++) {...
asked by 18.05.2015 / 05:27