
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
What happens when a function is called before its declaration in C?
If we do not use some function prototypes, and the function body is declared in some section which is present after the calling statement of that function. In such a case, the compiler thinks that the default return type is an integer. But if the function returns some other type of value, it returns an error. If the return type is also an integer, then it will work fine, sometimes this may generate some warnings.
Example Code
#include<stdio.h> main() { printf("The returned value: %d
", function); } char function() { return 'T'; //return T as character }
Output
[Error] conflicting types for 'function' [Note] previous implicit declaration of 'function' was here
Now if the return type is an integer, then it will work.
Example Code
#include<stdio.h> main() { printf("The returned value: %d
", function()); } int function() { return 86; //return an integer value }
Output
The returned value: 86
- Related Articles
- What happens when a virtual function is called inside a non-virtual function in C++
- When can I use a forward declaration in C/C++?
- What happens to the potential energy of a body when its height is doubled?
- (a) What happens during a bee sting? What is its remedy?(b) What happens during a wasp sting? What is its remedy?
- When can I use a forward declaration C/C++?
- What happens when iron is heated?
- What happens when sugar is heated?
- When is copy constructor called in C++?
- What happens when a copper plate is dipped in dilute acid?
- Function Expression vs Function Declaration in JavaScript?
- When a ball is thrown vertically upwards, its velocity goes on decreasing. What happens to its potential energy as its velocity becomes zero?
- What happens when more restrictive access is given to a derived class method in C++
- What is the difference between a definition and a declaration in C++?
- What is the “get” keyword before a function in a class - JavaScript?
- What is the proper declaration of main in C++?

Advertisements