![]() |
| ||
| Using isdigit Hi Everyone, I need help with using isdigit in C. What I am trying to do is verify that the user input is numeric. In my program, as is, I get the error: line (21) : error C2061: syntax error : identifier 'isdigit'. If I remove the "if" from in front of the" isdigit" it will run but not give me the results that I need. It runs thru the program as if it where 0 and goes to my 3rd "if" statement, printing the you have 18 years to wait to vote, then it prints "You did not enter a digit". Here is my code; /* CSS 561 Prograqmming ConceptsCan someone please help me out? Tyserman5674 |
| ||
| Re: Using isdigit Errors : 1> You cannot code like this.isdigit() is a function: if isdigit(cResponse);It should be if(isdigit(cResponse)); 2>Be sure of the portability of scanf_s 3>Your program has a lot of mistakes. * {Useless Braces.*The semicolon after your problematic if statement.With that its as good as not including that if statement. *isdigit() checks for a digit 0 1 2 3 4 5 6 7 8 9 not for a number. And many others so check. And ya mainly use code tags.Is that so difficult??? |
| ||
| Re: Using isdigit the answer to your basic problem: if isdigit(cResponse);is incorrect. it should be if (isdigit(cResponse)) (1) an if-statement must be entirely enclosed in parentheses. (2) an if-statement -- if the condition is evaluated as true -- will execute either one line of code terminated with a semi-colon or a block of code contained between the curly braces, '{' and '}' so even if you framed the conditional statement correctly, since you put the semicolon directly after the if statement, it still would never execute anything when the condition evaluated true. . |
| ||
| Re: Using isdigit I want to thank you all for your input, I did get it solved. |
| All times are GMT -4. The time now is 9:09 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC