In C language keyword const
has nothing to do with constants. In C language, by definition the term “constant” refers to literal values and enum constants. This is what you have to use if you really need a constant: either use a literal value (define a macro to give your constant a name), or use a enum constant.
(Read here for more details: Shall I prefer constants over defines?)
Also, in C99 and later versions of the language it possible to use non-constant values as array sizes for local arrays. That means that your code should compile in modern C even though your size
is not a constant. But you are apparently using an older compiler, so in your case
#define SIZE 10
is the right way to go.
Related Posts:
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- what is the difference between uint16_t and unsigned short int incase of 64 bit processor?
- Why am I getting “void value not ignored as it ought to be”?
- 1 = false and 0 = true?
- char *array and char array[]
- Get a substring of a char*
- What causes the Broken Pipe Error?
- Strings and character with printf
- What is EOF in the C programming language?
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?
- Write to .txt file?
- Reading from file using read() function
- What is the difference between ++i and i++?
- warning: assignment makes integer from pointer without a cast
- munmap_chunk(): invalid pointer
- printf() formatting for hexadecimal
- The importance of c enumeration (typedef enum) [duplicate]
- What does #pragma once mean in C? [duplicate]
- Connect: Socket operation on non-socket
- “Initializer element is not constant” in C
- How do you do exponentiation in C?
- Printing long int value in C
- Undefined reference to pow( ) in C, despite including math.h [duplicate]
- Undefined reference to pow( ) in C, despite including math.h [duplicate]
- C programming, error: called object is not a function or function pointer
- How to convert an int to string in C?
- Process finished with exit code 11 | Error during malloc [duplicate]
- How does wait(NULL) exactly work?
- How to replicate vector in c?
- Try catch statements in C
- How do I create an array of strings in C?
- How to check if a string is a number?
- C compile error: “Variable-sized object may not be initialized”
- What does WEXITSTATUS(status) return?
- Difference between a Structure and a Union
- Xcode – Warning: Implicit declaration of function is invalid in C99
- Error: control may reach end of non-void function in C
- The difference between stdout and STDOUT_FILENO
- C language: float % float why expression must have integral type
- Reading \r (carriage return) vs \n (newline) from console with getc?
- Invalid pointer error on invoking free() after malloc in C
- where does stdio.o live in linux machine?
- In C, how should I read a text file and print all strings
- Using Dynamic Memory allocation for arrays
- What does “Size in TCHARs” means?
- Python ? (conditional/ternary) operator for assignments
- What’s the difference between a file descriptor and file pointer?
- return makes integer from pointer without a cast [-Wint-conversion] return candidate
- Math constant PI value in C
- Cygwin – Makefile-error: recipe for target `main.o’ failed
- Why am I getting “undefined reference to sqrt” error even though I include math.h header?
- Why am I getting “undefined reference to sqrt” error even though I include math.h header?
- How can I use an array of function pointers?
- Expected declaration specifier error in function
- Valgrind: Invalid read of size 1
- Multiple definition of … linker error
- Does sizeof return the number of bytes or the number of octets of a type in C?
- Zero an array in C code
- Passing an array by reference in C?
- Excess elements in char array initializer error
- Encrypt with private key and decrypt with public key
- Warning: return from incompatible pointer type in C
- How to generate a random number between 0 and 1?
- strcmp giving segmentation fault
- What does “pointer being freed was not allocated” mean exactly?
- How to use timer in C?
- What is the difference between stdin and STDIN_FILENO?
- Memory Clobbering Error
- Check if input is integer type in C
- Iterate through a C array
- Allocating string with malloc
- How to simply convert a float to a string in c?
- What is the difference between char array and char pointer in C?
- hash function for string
- double free or corruption (!prev) error in c program
- What happens during a “relocation has invalid symbol index” error?
- What does this GCC error “… relocation truncated to fit…” mean?
- Using floats with sprintf() in embedded C
- Printf width specifier to maintain precision of floating-point value
- Two or more data types in declaration specifiers error
- ‘sprintf’: double precision in C
- C printing bits
- Error: “Access not within mapped region at address” (Valgrind)
- How do I find the time complexity (Big O) of while loop?
- Why do we use NULL in strtok()?
- How to convert string to float?
- What is `S_ISREG()`, and what does it do?
- typedef struct pointer definition
- How does the fscanf function work?
- Math constant PI value in C
- error: ISO C forbids nested functions – What’s wrong?
- getline() vs. fgets(): Control memory allocation
- Carriage return in C?
- Segmentation fault- strcat
- fgetc(stdin) in a loop is producing strange behaviour