Error saying missing function prototype, though Iv'e declared it

This is a discussion on Error saying missing function prototype, though Iv'e declared it within the C Programming forums, part of the General Programming Boards category; The program keeps telling me that I need to declare a function prototype for initialise_com_port But Iv'e done that, can ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    71

    Error saying missing function prototype, though Iv'e declared it

    The program keeps telling me that I need to declare a function prototype for initialise_com_port
    But Iv'e done that, can anyone tell me what's going on?

    Code:
    #include <stdio.h>
    #include <process.h>
    #include <conio.h>
    
    void initialise_com_port();
    void sort_bytes();
    void create_screen();
    void create_file();
    
    char reply, key;
    
    int main()
    {
       initialise_com_port();
    
       getch();
       return 0;
    }
    
    void initialise_com_port()
    {
       printf("     PACKET CAPTURE, DISPLAY AND STORE-TO-DISK PROGRAM\n\n");
       printf("       THIS PC WILL CAPTURE 9600 BIT/S DATA COMING IN\n");
       printf("       ON SERIAL PORT COM1 AND DISPLAY THE DATA\n\n\n");
       printf("     Type C and then press Enter to capture and display: ");
       scanf("%c", reply);
    
       if (reply == 'C')
       {
          clrscr;
          printf("Below are given the values of the bytes in the data field");
          printf(" of each identified packet.\n\n");
          sort_bytes();
          create_screen();
          printf("To store to disk, type D and then press Enter.\n");
          printf("Not to store to disk but to capture again type C and press");
          printf(" Enter\n");
          printf("To return to DOS, type F and then press Enter TWICE");
          scanf("%c", key);
    
    
          if (key == 'C')
          {
             sort_bytes();
             create_screen();
          }
    
          if (key == 'D')
          {
             create_file();
          }
    
          if (key == 'F')
          {
             printf("You have decided to exit from the program.");
             printf("\nPress Enter");
          }
    
    
          else
          {
             printf("You did not enter C. Program assumes you want to exit");
          }
       }
    }
    
    void sort_bytes()
    {
       printf("Hello from sort_bytes!");
    }
    
    void create_screen()
    {
       printf("Hello from create_screen!");
    }
    
    void create_file()
    {
       printf("Hello from create_file!");
    }

  2. #2
    Registered User
    Join Date
    Oct 2004
    Posts
    120
    The error I get is that clrscr is not defined. I comment that out and it builds fine.

    I'm using VC++ .NET to compile.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    71
    I'll try the same, thanks, I'm using Borland C++ builder ver 6

    EDIT: same error still, to me this program makes sense, then again, I'm just a beginner.
    Last edited by Guti14; 10-06-2004 at 10:44 PM.

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    120
    The program makes perfect sense. I read over and compiled it and its fine. There might be some setting in Borland that needs tweaking to work right, but I have never used Borland so I can't help you there.

    You can also try downloading a free C/C++ compiler and trying that out.

  5. #5
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    maybe you forgot the () after clscr
    Code:
    clscr()
    maybe it isn't in your conio.h because it isn't standard.
    There doesn't have to be anything in their like what I use doesn't even have that function.

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    i also have bcb6
    i changed
    Code:
    void initialise_com_port();
    void sort_bytes();
    void create_screen();
    void create_file();
    to
    Code:
    void initialise_com_port(void);
    void sort_bytes(void);
    void create_screen(void);
    void create_file(void);
    and changed
    Code:
    clscr;
    to
    Code:
    clscr();
    and it came back with no warnings at all

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,834
    Probably means that the code was being compiled as "C++" rather than "C"
    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.

  8. #8
    ---
    Join Date
    May 2004
    Posts
    1,379
    i compiled it as c and it had the same warning about the function prototype
    it must be a borland thing

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could have just had main at the bottom of your source code, and not bothered prototyping at all.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 02:17 AM
  2. variables when declared inside or outside a function
    By jas_atwal in forum C Programming
    Replies: 6
    Last Post: 12-14-2007, 02:42 PM
  3. Replies: 13
    Last Post: 08-24-2006, 01:22 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 09:57 AM

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