I want to take a 2D char array as an input in a function (actually my 2D array is global and the function doesn't have inputs) , change the values in it and then return another 2D char array.
char stoixeia[50][7];
int main(int argc, char *argv[])
. . .
if (strcmp(answer, "Gift")==0)
{
gift();
}
char gift ()
{
int i,j,m;
int wrong=0;
int k=0;
char usern[50];
while(wrong=0)
{
printf("Enter the username that you want to Gift:\n");
scanf("%s", &usern);
for (i=0; i<50; i++)
{
if (*usern==stoixeia[i][0])
{
wrong=1;
k=i;
}
}
}
m=strlen(usern);
for(i=0; i<m; i++)
{
stoixeia[k][6]= stoixeia[k][6] + 10;
}
return stoixeia[50][7];
}
My thought was that if i declare my array as a global one everything would change in my functions and the array will get "updated". The compiler doesn't show any errors but when I run the programm and my answer is Gift the .exe stops working. Can you suggest me anything? Thank you
stoixeia[50][7];is out of bound. 2. to return an array, you need to have achar **, at least.while(wrong=0)-->while(wrong==0)usernit doesnt find anything and it always asks me to give another username