I'm starting school again in a few weeks and I'm trying to practice a bit. I want to make a function that takes a word and turns it backwards (word -> drow).
I need to know the length of the word of course. I use another function to determine its size. Don't want to use any built-in functions.
This is the function that determines the length of the word:
int largopal(char * palabra) //Devuelve la cantidad de caracteres de la palabra
{
int counter = 0;
while (palabra[counter] != '\0')
{
counter++;
}
return counter;
}
And this is the function that turns the word backwards:
void darvuelta(char *pal){
int c = 0, i;
const int l = largopal(pal);
char t[l];
for (i = 0; i < l; i++){
}
}
Before going on with my for
, I need to know why the compiler is asking me to give "a constant expression" in char t[l]
and fix it.
I'm using Visual Studio 2012, the filename extension is c
, the project was created as a win32 console application, I'm using Win7 enterprise, let me know if you need more info. First question made here.
Thanks in advance.
Dimas.