Thread: functions undeclared

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    functions undeclared

    hello
    can any body how to correct this program
    Code:
    #include<iostream>
    #include<conio.h>
    #include<dos.h>
    using namespace std;
    void main()
    {
         char nm[25];
         cout<<"Enter your name: "<<endl;
         cin>>nm;
         for(int i=0;i<25;i++)
         {
                 cout.write(nm,i);
                  delay(100);
         }
        
         getch();
    }
    The errors are
    'main must return int'
    'delay' function undeclared

    Iam using DevCpp iam new to it before i was using Turbo C++
    please anybody help me

  2. #2
    Registered User
    Join Date
    Jan 2006
    Location
    Europe/Belgrade
    Posts
    78
    Instead of
    Code:
    void main()
    put
    Code:
    int main()
    delay() is not declared in headers that you included, so find the appropriate header and include it.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    If you are using delay() to make the program wait, you can use sleep() to achieve the same
    result. It is declared in the windows.h header file.

    Oh, and like Karas said, main returns an int, and dos.h is a very dated header. Turbo C++ is
    an old compiiler nowdays, most of the functions it incorperates will nor work on todays more modern compilers. Read the documentation in the help files on DevC++ to find out more information
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is it legal to have functions within functions?
    By Programmer_P in forum C++ Programming
    Replies: 13
    Last Post: 05-25-2009, 11:21 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  4. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  5. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM