#include <stdio.h>
int a, b;
int main() {
int *p;
a = 2;
b = 15;
p = intToBin(a,b);
printf("The value of the return value p is: %d\n",p);
}
int * intToBin(int a, int b) {
while(b > 0) {
c = b /a;
d = b % a;
printf("The expansion of %d is: %d * %d + %d\n",b,c,a,d);
b = c;
}
return 5;
}
This does not work.
I am trying to pull in what I have written for this:
https://www.youtube.com/watch?v=8afbTaA-gOQ
Perhaps I will check out:
https://overiq.com/c-programming-101/returning-a-pointer-from-a-function-in-c/
trying: https://www.tutorialspoint.com/cprogramming/c_return_arrays_from_function.htm
https://www.geeksforgeeks.org/how-to-return-multiple-values-from-a-function-in-c-or-cpp/
try to returning exponent and array: ^^^^
The message I am getting from messing with this is, don't mix structs with arrays in them with pointers to structs as return types. It gets one into trouble.
No comments:
Post a Comment