- #1
nobahar
- 497
- 2
Hello!
I am sure I am again missing something obvious:
I tried to declare the array and assing value within main() as follows:
I can declare and initialise together before main():
and within main():
Is this an actual "restriction" or am I doing something wrong? The textbook I am working through gives me no guidance on this.
Thanks in advance!
I am sure I am again missing something obvious:
I tried to declare the array and assing value within main() as follows:
Code:
#include <stdio.h>
float array_1[10];
int main( void )
{
array_1[10] = { 1,1,2,3,4,5,6,7,8,9 };
...other stuff...
return 0;
}
I can declare and initialise together before main():
Code:
#include <stdio.h>
float array_1[10] = { 1,1,2,3,4,5,6,7,8,9 };
int main( void )
{
...other stuff...
return 0;
}
and within main():
Code:
#include <stdio.h>
int main( void )
{
float array_1[10] = { 1,1,2,3,4,5,6,7,8,9 };
...other stuff...
return 0;
}
Is this an actual "restriction" or am I doing something wrong? The textbook I am working through gives me no guidance on this.
Thanks in advance!