Hallo shaswat!
This way was one of the elder standards of c
Code:
// Forward declaration of a function
#include <stdio.h>
void tom(void)
{
static int jerry;
printf("%d\n", ++jerry);
}
int main()
{
// void tom(), tom(); it is in modern standards obsolete
tom(),
tom();
return 0;
}
When you work with bigger source code it is useful to split the code in
more files. I think one of the steps to go to this solution is the second way.
example:
Code:
#include <stdio.h>
void tom(void); // declaration
int main()
{
// void tom(), tom(); it is in modern standards obsolete
tom(),
tom();
return 0;
}
//definition
void tom(void)
{
static int jerry;
printf("%d\n", ++jerry);
}
elder way for a definition of a function:
Code:
/*
* char *
* mid (char *dest, char *str, int pos, int n)
*
*
* This function works very much like the BASIC function MID$.
* It returns a pointer to a character stringing containing n
* characters (null padded if needed) from str starting from position
* pos (remember: since C is zero based, the first position is
* postion 0, not position 1). The new string (dest) is assumed
* to be large enough to hold the result. Not also the external
* declaration of strncpy. This is needed for Lattice C large
* model copilation to work (since int's and char *'s are not the
* same size in that memory model).
*/
char *mid (dest, str, pos, n)
register char *dest, *str;
register int pos, n;
{
extern char *strncpy ();
/* Do a strncpy () to fill
the new string with the
proper characters */
new_string = strncpy (dest, &str[pos], n);
/* Return the pointer to the result */
return (dest);
} /* mid */
This example was written 1986 , May 25th
modern syntax:
Code:
char *mid (char *dest, char *str, int pos, int n)
{
extern char *strncpy ();
/* Do a strncpy () to fill
the new string with the
proper characters */
new_string = strncpy (dest, &str[pos], n);
/* Return the pointer to the result */
return (dest);
} /* mid */
The keyword 'register' is also obsolete.