Thread: Using Checks in C - Help!

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    4

    Using Checks in C - Help!

    hi,

    friend of mine did coding for checks because i had to submit project yesterday but today when i was check how he did it i am unable to understand

    also what is isdigit


    here is the code:

    Code:
    int checkNumber(char [], int);
    int checkLetters(char []);
    
    ----------------------
    
    int checkNumber(char number[], int allowDots) {
        
        for (int i = 0; i < strlen(number); i++) {    
        
            if (!allowDots)
        
            if (!isdigit(number[i]))
        
            return 0;
        
        }
        
        return 1;
    
    }
    
    int checkLetters(char string[]) {
        
        for (int i = 0; i < strlen(string); i++) {    
              
               if (isdigit(string[i]))
              
                  return 0;
        
        }
        
        return 1;
    
    }

  2. #2
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    4
    deadplanet, yes i know how while and loop statement works.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Then use some sample input and go through it on pen and paper, writing down the new values of the variables at each line.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    rather than ask 'what is 'isdigit' here' and hope for a reply, why not google isdigit and find the answer in about 5 seconds with no waiting

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. for loop, multiple checks
    By parad0x13 in forum C++ Programming
    Replies: 7
    Last Post: 02-17-2009, 11:59 PM
  2. Input Checks
    By Elements in forum C Programming
    Replies: 5
    Last Post: 04-25-2006, 07:41 PM
  3. Heuristic Checks
    By cloudy in forum C++ Programming
    Replies: 2
    Last Post: 02-12-2006, 04:08 PM
  4. checks for bad input
    By kocika73 in forum C Programming
    Replies: 8
    Last Post: 09-10-2004, 10:28 AM
  5. No Checks i CheckBox
    By CodeJerk in forum Windows Programming
    Replies: 1
    Last Post: 06-09-2003, 10:50 AM