I made this little program to count how many 'en's there are in a string. It does work, but I get an error saying there's stack smashing detected. I do not understand how to solve this... Can anyone give me a tip?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char s[30];
int getal=0, e, n;
int i = 0;
gets(s);
for (; s[i] != '\0'; i++) {
e =(s[i] == 'e');
n =(s[i + 1] == 'n');
if (e && n)
getal++;
}
printf("Het aantal bedraagt: %i", getal);
return 0;
}