Whats this error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats this error?

I got this one in another one switched to matrix. Can't understand what it means https://code.sololearn.com/cd5CmQJZu6ZA/?ref=app

15th Jan 2019, 5:02 PM
Akib
Akib - avatar
4 Answers
+ 1
line 17 i think the modulo "%" is the appropriate operator in this situation : int k = rand() % allen; also in line 18 replace "plen[i]" by "pass[i]". even though do those tasks above your program will not work as you expect, it may produce garbage values or may crash or something else. the problem is you try to return address of a local variable which is not advised, as knowing local variables may not exist in memory after function call is over, in simple words, functions can’t return arrays in C/C++ so in order to get around this problem, try using dynamically allocated array: https://code.sololearn.com/ckwlZ65Cg85R/#cpp
15th Jan 2019, 5:55 PM
MO ELomari
0
Messed that % up cause you (meaning me) use* in java script ;). And that plen[i].. 👀. Use dynamic array Thanks I will try that.
15th Jan 2019, 6:08 PM
Akib
Akib - avatar
0
Can't fix it.
16th Jan 2019, 2:20 PM
Akib
Akib - avatar
0
turn out line 17 to be like that ( as i said before the modulo operator is the best approach here ( since you want to get a random index between 0 and 24) ) : int k = rand() % 24;
16th Jan 2019, 3:11 PM
MO ELomari