Answer the question
In order to leave comments, you need to log in
Why does the program give the wrong result?
I'm probably sick of my stupid questions =) Let's continue!
In order not to write a long question, I will give a link:
https://github.com/yarkovaleksei/passgen/issues/1
The code is here:
https://github.com/yarkovaleksei/passgen/blob/mast...
I am now in local I'm trying to fix a branch, but there's such a trash ...
Here's how I'm trying to fix it:
if (length < 1)
{
while (isTyped != 1)
{
int t;
char *ct = (char *)malloc(4); // хочу ограничить ввод числом 999
printf("%s\n", _("Type in a password length"));
scanf("%s", ct);
if (isNumber(ct) == 1) // функция isNumber принимает char[], поэтому изврат с scanf("%s", ct)
{
t = atoi(ct); // конвертируем в число, если строка из цифр (убейте меня)
if (t < 1) {
isTyped = 0;
} else {
length = t;
isTyped = 1;
}
} else {
isTyped = 0;
}
}
}
Answer the question
In order to leave comments, you need to log in
FIG knows, there is an assumption in main.c
setlocale(LC_ALL, "");
#ifdef PACKAGE_LOCALE_DIR
bindtextdomain(PACKAGE_NAME, PACKAGE_LOCALE_DIR);
#else
#error Please use flag -DPACKAGE_LOCALE_DIR="locale"!
#endif
textdomain(PACKAGE_NAME);
some of this gives extra text to stdout the path to localization, but it is cached, caches are reset upon program completion
An overflow occurs, scanf reads the entire line up to the newline character, but the buffer is only 4 bytes, and the data is overwritten beyond the buffer. Apparently, the file name is stored further, which is displayed. It is necessary to use safe scanf (in Windows it's scanf_s, in Linux I don't know).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question