compiler warning message

This is a discussion on compiler warning message within the C Programming forums, part of the General Programming Boards category; Hi When I compile the program, the compiler return a warning message: "Call to function 'printStatistics' with no prototype" Can ...

  1. #1
    Registered User alice's Avatar
    Join Date
    Mar 2004
    Posts
    36

    compiler warning message

    Hi

    When I compile the program, the compiler return a warning message: "Call to function 'printStatistics' with no prototype"
    Can someone told me how can I correct it? thk a lot

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    #define TESTSET 1000000
    
    int counter[3]; /* to hold the occurence of 0, 1, and 2 */
    
    void printStatistics() {
      int i;
    
      printf("Value       Frequency\n");
      for (i=0; i<3; i++) {
        printf("%d            %d\n", i, counter[i]);
      }
    }
    
    
    void generateStatistics(int number) {
      int i;
      int random;
    
      srand(time(NULL));  /* set a new random seed */
      for (i=0; i<number; i++) {
        random = rand() % 3; /* generate 0, 1, or 2 */
        counter[random]++;
      }
    }
    
    void main() {
    
      generateStatistics(TESTSET);
      printf("Frequencies of 0, 1, and 2 in %d values\n", TESTSET);
      printStatistics();
    
      getchar();
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    > void printStatistics() {
    This isn't a prototype, it's an old style function definition
    void printStatistics( void ) {

    It would be OK in C++ though, because foo() and foo(void) are the same thing, but that's not the case in C

    void main as noted in my other reply
    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.

  3. #3
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    salut
    si vous utilisez (turbo c) sous ms-dos veuiellez ecrire le mot void dans les parenthese
    sinon ilfaut voir si vous avez oubliez un sous programme sous c++ qui est deja en marche et qui utilise un void main()
    merci...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Making a script language?
    By Blackroot in forum Game Programming
    Replies: 10
    Last Post: 02-16-2006, 01:22 AM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  4. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 06:16 AM
  5. Compiler warning question
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 12-05-2003, 04:39 AM

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