2017-10-19 121 views
-3
case 'f': 
      printf ("Great!!! lets create your fixed account\n"); 

     printf ("\nA minimum purchase of 1000 units is required for this 

account\n"); 
      printf ("\nPrice per unit as of Sep. 15 is $52.69\n") 
; 
      printf ("\nPlease enter required amount of units\n"); 

      scanf("%d",&amount); 


      if (isdigit(amount)) 

       { 
       printf ("invalid input\n"); 
       success = 'f'; 
       break; 
+1

你試過了什麼? – AntonH

+0

我試過了isdigit,isalpha函數,但都沒有工作 – v620

+0

你是否按照你的其他問題的意見中的建議?因爲有關於如何使用'scanf'來查看是否讀取了整數值的明確解釋。 – AntonH

回答

0

閱讀doc on scanf,然後更改您的代碼以檢查您的調用scanf的返回值。如果用戶輸入的值與當前代碼頁中的字符匹配,則數字(金額)只能成功,因此請停止調用它。

相關問題