idk much about c++ pointers but shouldn't it be:
void getINPUTandClear(int & something)
I'm having a stroke or some shit but i cant seem to get this working (it been a while since i deal with pointers).
I have a function that takes in a int pointer
I declared my varCode:void getINPUTandClear(int * something)
and I'm trying to pass the point to the function byCode:int day = -1; \\or int * day; *day= -1;
but all of those wouldn;t work. What's am i doing wrong?Code:getINPUTandClear(&day); \\or getINPUTandClear(*day); \\or getINPUTandClear(day);
idk much about c++ pointers but shouldn't it be:
void getINPUTandClear(int & something)
. . . malsignature.com . . .
[ global rules ] [ scam report ] [ image title ] [ name change ] [ anime force ]
[ league of legends marketplace rules ] [ battlefield marketplace rules ]
"because everytime you post a picture of anime in here
your virginity's time increases by 1 month"
~Smoke 2/18/2018
Former Staff 09-29-2018
Battlefield Minion 07-21-2018
Premium Seller 03-04-2018
Publicist 12-10-2017
League of Legends Minion 05-31-2017
Premium 02-05-2017
Member 10-13-2013
Use references wherever possible, use pointers only if you can't avoid them.
Regardless, if you want to use pointers, this should work just fine:
or else if you declare day as a pointer:Code:void getINPUTandClear(int* something); int day = -1; getINPUTandClear(&day);
Code:void getINPUTandClear(int* something); int* day; *day = -1; getINPUTandClear(day);
In C:
(U should use prints to understand how things work.)
Code:#include <stdio.h> double minmaxavg(double array[], int num, double *max,double *min); double minmaxavg(double array[], int num, double *max,double *min){ int i; double sum =0; for(i =0;i< num;i++){ if(array[i] > *max){ *max = array[i]; } if(array[i] < *min){ *min = array[i]; } sum +=array[i]; } return sum; } void main(){ double sum; double max =1; double min =1; double arr[] = {1,3,2,5,4,6,8,7,99,0}; //double *pArr; double *pMax; double *pMin; //pArr = &arr; pMax = &max; pMin = &min; sum =minmaxavg(arr,10,pMax,pMin); printf("sum:%g min:%g max:%g",sum,min,max); }
Last edited by Kappatos; 06-03-2017 at 06:59 PM.
youtube com/watch?v=Fa6S8Pz924k
glhf