I need a small help for my c++ function. I am writing a function called "calculate". The Pr[o] array is a data in a file called "fileX" and is read from the file properly, there is no problem in that part. I have problem in the calculate function because Pr[o] is underlined with red , since it is error. I guess the filename should be the parameter of the calculate function. I do not know how to do that. How can I transfer these data which is read from the file in the function.Can you help me please ? Thank you so much
1 2 3 4 5 6 7
double calculate()
{
for (int o = 0; o < 12; ++o) {
yy += 5* Pr[o];
}
return 0;
}
Hello.. learner999 ! You need to be more specific.. What you just shown is just a function that has only a loop inside.. You need to provide more code, we need to know what the function do calculate. Where did you open the fileX how did you do that.. ? With one single loop no one can help you.
In both cases where are these variables defined? How does the function have access to them?
In the for loop using a lower case "o" is a bad idea. Usually "i", "j" and "k" are used in for loops and when working with an array I like to use either "index" or "idx" for better readability.
In 2 D arrays I like using "row" and "col".
Is there a point to having the function return a value the is just (0) zero?