Why does this accept invalid input?

前端 未结 5 2171
一个人的身影
一个人的身影 2020-12-22 09:52

I have a triangle program in c

#include 

// A function which decides the type of the triangle and prints it
void checkTriangle(int s1, int s         


        
5条回答
  •  梦毁少年i
    2020-12-22 09:59

    %d accepts only integer. try with %x in scanf() for hex-decimal input.

    Better you can get input as string then check using isnumeric() else use scanf("%[^\n]s", word) like @mou suggested.

提交回复
热议问题