Dev C++ Func Problem

This is a discussion on Dev C++ Func Problem within the C++ Programming forums, part of the General Programming Boards category; I'm using Dev-C++ and I tried to compile the below code: Code: #include <iostream> using namespace std; int validnum(int lower,int ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    66

    Dev C++ Func Problem

    I'm using Dev-C++ and I tried to compile the below code:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int validnum(int lower,int higher);
    
    int main()
    {
        cout << "Please enter your birthday. Enter the year: ";
        int year = validnum(1990,1998);
        cout << "Enter the month: ";
        int month = validnum(1,12);
        int date = 0;
        switch(month)
        {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                    date = validnum(1,31);
                    break;
            case 4:
            case 6:
            case 9:
            case 11:
                    date = validnum(1,30);
                    break;
            case 2:
                    if (year%4 == 0)
                    {
                         date = validnum(1,29);
                         break;
                    }
                    else
                    {
                         date = validnum(1,28);
                         break;
                    }
        }
        
        cout << endl
             << "Your birthday is on "
             << date
             << "."
             << month
             << "."
             << year
             << "."
             << endl;
        
        system("PAUSE");
        return 0;
    }   
        
        
    int validnum(int lower,int higher)              //function to check whether number is valid
    {
        int num = 0;    
        cin >> num;
        while((num < lower)||(num > higher))                    //tell user that number is invalid
        {
            cout << "Your number is invalid, please try again: ";
            cin >> num;
        }
        return num;
    }
    but it resulted in the following errors:
    1. too many filenames. Type cc1plus -- help usage info.
    2.unrecognized option 'quieu'
    3.output filename specified twice

    I thought this kind of errors might be a compiler problem, so I cheated and look at the book's answer key and inserted the code in the compiler:

    Code:
    #include <iostream> 
    using namespace std;
    
    int validNum(int lower, int upper);
    
    int main()
    {
      cout << "Enter your birthdate here.  Enter the year first. " << endl;
      int year = validNum(1900, 1998);
    
      cout << "Now the month. ";
      int month = validNum(1, 12);
      
      cout << "Now the date. ";
      int date = 0;
      switch(month)
      {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12: 
          date = validNum(1, 31);
          break;
        case 4:
        case 6:
        case 9: 
        case 11:  
          date = validNum(1, 30);
          break;
        case 2: 
          if(0==year%4)
            date = validNum(1, 29);
          else
            date = validNum(1, 28);
      }
    
      cout << endl
           << "We have established that your date of birth is " 
           << month << "/" << date << "/" << year << "." << endl;
    
      return 0;
    }
    
    int validNum(int lower, int upper)
    {
      int data = 0;   
      cout << "Please enter an integer between " << lower << " and " << upper << ": ";
      cin >> data;
      while(data < lower || data > upper) 
      {
        cout << "Invalid entry; please re-enter: ";
        cin >> data;
      }  
      return data;
    }
    As I have thought, the compiler returned the same errors. Is there anyway to fix this problem? Or must I change my compiler?
    An Unofficial Cristiano Ronaldo Website : Ronaldo 7

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Nothing to do with your code, it's somewhere in the setup of your compiler / IDE

    Like these
    2.unrecognized option 'quieu'
    3.output filename specified twice

    I'd suggest you create a new project, and then copy/paste your code into the empty .cpp file it creates for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem running prog I wrote in Dev C++
    By KidMan in forum C Programming
    Replies: 8
    Last Post: 09-22-2005, 01:50 AM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. problem with using for loops with Dev C++
    By indigo0086 in forum C++ Programming
    Replies: 10
    Last Post: 08-10-2005, 11:04 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. typedef a func
    By trekker in forum C Programming
    Replies: 4
    Last Post: 07-02-2002, 05:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21