TheAlgorithms / C

Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
https://thealgorithms.github.io/C
GNU General Public License v3.0
19.29k stars 4.38k forks source link

[BUG] Input validation #1428

Open shrivalidutt opened 1 month ago

shrivalidutt commented 1 month ago

Description

The input validation logic in placex() and placey() is somewhat convoluted and can lead to an infinite loop if the user does not enter a valid position.

Expected behavior

If the user enters an invalid position, they should be prompted to enter a valid number without causing the program to get stuck in an infinite loop.

Actual behavior

leads to an infinite loop if the user does not enter a valid position.

Possible fix

adding input validation

Steps to reproduce

Execute the compiled program When prompted, enter an invalid move, such as a number outside the range of 1-9 or a letter. the program keeps prompting for input without handling invalid cases, it may cause an infinite loop if the input is never valid

Context

While trying to check what the output will be in case an invalid input is provided i came across this issue

Additional information

No response

VyankateshRohokale commented 1 month ago

ok , will check it out

siya0106 commented 1 month ago

/assign

Zaki2409 commented 1 month ago

Hi @shrivalidutt , I would like to contribute on this. Can you assign me this issue?

/assign

YdvAkash commented 2 weeks ago

in which file code of function present ?

VyankateshRohokale commented 2 weeks ago

in which file code of function present ?

you can contribute to it in sorting folder , and add a file in it and write your code