C - Avoiding the Function Prototype

Introduction

You can avoid the function prototype by define the function first and then use it.

Move the prompt() function from the bottom of the source code listing to the top, above the main() function.

Demo

#include <stdio.h> 

void prompt(void) 
{ 
      printf("C:\\DOS> "); 
} 

int main() //from w  w w  . j a  va 2  s. co  m
{ 
      int loop; 
      char input[32]; 

      loop=0; 
      while(loop<5) 
      { 
          prompt(); 
          fgets(input,31,stdin); 
          loop=loop+1; 
      } 
      return(0); 
}

Result

Related Topic