N
noridotjabi
Whilest I was browesing a tutorial today I came across the infromation
that in standard C variables must be decalred at the beginning of a
block. Meaning:
/****************************************************/
/* ... usual includes and such */
int var = 1;
if(var = 1){
printf("hello world\n");
}
int a = 10;
int b = 30;
printf("%d %d", a, b);
/* end return etc. */
/****************************************************/
Would form some kind of error and would need to be replaced with:
/****************************************************/
/* ... usual includes and such */
int var = 1;
if(var = 1){
printf("hello world\n");
}
{
int a = 10;
int b = 30;
printf("%d %d", a, b);
}
/* end return etc. */
/****************************************************/
This is news to me as I have never heard or seen anything like this.
Infact I have assumed (but have never confirmed) that C was even
equiped with a "naked block" feature. Can anyone offer any insight as
to what is going on here. Also please correct me if I have
misinturpreted someting as I expect that I might have.
Nori
that in standard C variables must be decalred at the beginning of a
block. Meaning:
/****************************************************/
/* ... usual includes and such */
int var = 1;
if(var = 1){
printf("hello world\n");
}
int a = 10;
int b = 30;
printf("%d %d", a, b);
/* end return etc. */
/****************************************************/
Would form some kind of error and would need to be replaced with:
/****************************************************/
/* ... usual includes and such */
int var = 1;
if(var = 1){
printf("hello world\n");
}
{
int a = 10;
int b = 30;
printf("%d %d", a, b);
}
/* end return etc. */
/****************************************************/
This is news to me as I have never heard or seen anything like this.
Infact I have assumed (but have never confirmed) that C was even
equiped with a "naked block" feature. Can anyone offer any insight as
to what is going on here. Also please correct me if I have
misinturpreted someting as I expect that I might have.
Nori