
- Forum
- Programming Talk
- C and C++
- Help in Resolving Error
Help in Resolving Error
This is a discussion on Help in Resolving Error within the C and C++ forums, part of the Programming Talk category; I got the following error when I ran my C program -Error C2734: ‘test’: const object must be initialized if ...
-
Help in Resolving Error
I got the following error when I ran my C program
-Error C2734: ‘test’: const object must be initialized if not extern
In my C program I have declared the const as below:
#include <stdio.h>
main()
{
const float test, sample = test;
.........
.........
}
Someone help me to resolve this.
-
It is essential that const data type cannot be not only changed but must be initialized when it is declared. But in your code you have assigned the const data type to a variable which is not advisable. It is because of this reason you are getting the error as -Error C2734: ‘test’: const object must be initialized if not extern. So initialize const value to some constant value
and your error would be resolved.

Reply With Quote





