How can I edit this code so it compiles on ISO C90 and not just ISO C99?

29 Views Asked by At

I'm currently running a shell project, I tried to compile the code using: `

gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh

The compilation method is mandatory for my project. The code compiles on ISO C99 (-std=gnu99), but returned the error: ISO C90 forbids variable length array when I used the above compilation method. How can I edit this code instead so it compiles on ISO C90?

This is the code I tried:

int i = 0, j = 0, k = 1;
int n = find_chars_number(s, sep, idx) + 1;
int array[n];
int o = 0;

array[0] = idx;

Error found on the line int array[n]; nb: find_chars_number is a function I invoked

0

There are 0 best solutions below