Answer the question
In order to leave comments, you need to log in
Why is the function not reading a character?
Hello! Is there a problem why the scanf() function from this program code does not read a character? Maybe I'm writing something wrong? Here is the program code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
float x1, x2;
int y1, y2;
char z1, z2;
srand(time(NULL));
system("chcp 65001");
printf("Задайте диапазон для целого числа:");
scanf("%d", &y1, &y2);
printf("%d\n", rand() % (y2 - y1) + y1);
printf("Задайте диапазон символов:");
scanf("%c%c", &z1, &z2); // вот именно в этом месте не работает
printf("%c", rand() % (z2 - z1) + z1);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question