Const variables

  • Thread starter Christian Christmann
  • Start date
C

Christian Christmann

Hi,

is it valid (acc. to ANSI-C 99) to assign an uninitialized
const value a constant afterwards, like

const int constInt;
int main( void )
{
constInt = 10;
return 0;
}

Regards,
Chris
 
V

Vladimir Oka

Christian said:
Hi,

is it valid (acc. to ANSI-C 99) to assign an uninitialized
const value a constant afterwards, like

const int constInt;
int main( void )
{
constInt = 10;
return 0;
}

No, it is not. It is OK, however, to initialise it:

const int constInt = 10;
 
R

Richard Bos

Christian Christmann said:
is it valid (acc. to ANSI-C 99) to assign an uninitialized
const value a constant afterwards, like

const int constInt;
int main( void )
{
constInt = 10;
return 0;
}

No.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top