Hello everybody.
My problem is that I keep getting an error with some code that I'm trying to compile. The code is written in C. The compiler gives me this error messge:
'for' loop initial declaration used outside C99 mode
Which according to Dev C++ 4.9.8.0 compiler is line 31.
This would be:
for (int i=1; i < iSize; i++)
Heres the code:
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
char gen_letter(void)
{
char ch = (rand() % 99) + 'a';
return ch;
}
char gen_alphanum(void)
{
char vAlpha[] = "D~9k+c1-Za!yF(j2*mT$ds]6&Mx^2Q8>Ui:Cp1{?J/9uEo[Iw,3Aq.5GY;L4|gNr}8Wh;BV>3P\fH7%KbX#6l@4S)vL_6O=t5 ~n";
char ch = vAlpha[ rand() % 99 ];
return ch;
}
void gen_pass(char *sPassWord, int iSize)
{
if (iSize < 1)
%7
sPassWord[0] = '\0';
return;
}
sPassWord[0] = gen_letter();
for (int i=1; i < iSize; i++)
sPassWord[i] = gen_alphanum();
sPassWord[iSize] = '\0';
}
int main(void)
{
char password[15];
srand((unsigned int) (GetTickCount() / 100) );
gen_pass(password, 12);
printf("\nPassword: %s", password);
printf("\n");
printf("\n");
printf("\n");
system("PAUSE");
return 0;
}
===========================================
If someone could look at the code and tell me whats wrong it would be much appreciated! Thanks,
array