I have a problem with a character array in my c program.
The program immediately shutdown when I run it. I think the problem is somewhere with passing the character array in the function.
here's my code:
#include<stdio.h>
#include<string.h>
#define DAGEN 7
void inlezen(int[][DAGEN], char[][12]);
int main(void)
{
int i;
int temp[1][DAGEN];
char dagen[7][12];
strcpy(dagen[0], "MA");
strcpy(dagen[1], "DI");
strcpy(dagen[2], "WOE");
strcpy(dagen[3], "DO");
strcpy(dagen[4], "VR");
strcpy(dagen[5], "ZA");
strcpy(dagen[6], "ZO");
inlezen(temp, 1, DAGEN, dagen, 7, 12);
}
void inlezen(int t[][DAGEN], char d[][12])
{
int i;
for (i = 0; i < DAGEN; i++)
{
printf("Geef de temperatuur overdag van %s", d[i]);
scanf("%d%*c", &t[0][i]);
}
for (i = 0; i < DAGEN; i++)
{
printf("Geef de temperatuur 's avonds van %s", d[i]);
scanf("%d%*c", &t[1][i]);
}
}
I've edited my code, but it still doesn't work.
inlezen(temp, 1, DAGEN, dagen, 6, 12);six parameters when your function only takes two?void inlezen(int t[][DAGEN], char d[][12])int temp[2][DAGEN]; char dagen[DAGEN][12];,scanf("%d", &t[0][i]);,scanf("%d", &t[1][i]);0through6(inclusive)) you specify7as the size.