0

Stuck on Output

Greetings fellow Coders, Been working on a larger form of code that will print out a Series of symbols equal to a randomly generated number. In this Code i have it made where it passes through a function going into a reference variable and using a separate function to put it in an array then output it out as a Cstring. Unfortunately i got through what i believe to be the majority of the code done properly, but i'm stuck on the last bit being the output segment in the below code. https://code.sololearn.com/c15j45QoX36I/#cpp In coding i've done thus far, i have a random number become generated by having it pass through the function refrandom, which creates a random number between 1 and 30. Afterwards in pointfill it will generate the Designated symbol and put it into the array. Finally it should output the amount of symbols put into the array out as a cstring. However i'm not sure if I did that correctly enough, i thought i had a grasp on cstring. But it appears i'm still a bit of a novice at it.

2nd Nov 2018, 6:41 AM
Ryan Finley
1 ответ
+ 7
"truly randomize number, is needed for any random generator" There's no such thing as "true randomness" in a deterministic machine like a computer. "creates a random number between 1 and 30" No, it won't! :) lower bound + rand() % (upper bound + 1 - lower bound) E.g: 1 + rand() % (30 + 1 - 1); Where is the return statements of the two functions?! change the signatures to return void. The rest seems well-defined. Just print out the content of three arrays to output like so printf("%s\n", x); printf("%s\n", y); printf("%s\n", z); Edit: Indeed, it can be printed out using cout like so cout << x << endl; without a problem, since << operator knows how to stop reading the content of a char array when reached to the null terminator.
2nd Nov 2018, 6:57 AM
Babak
Babak - avatar