- #1
leroyjenkens
- 616
- 49
Hello, I wrote this program but it's not working. Here's what the program is supposed to do:
"Write a program that reads data into a and b using the pointers x and y. The program then multiplies the value of a by b and stores the results in c using the pointers x, y, and z. Finally, it prints all three variables using the pointers x, y, and z."
Mine let's me type in two numbers, but it returns the number 2 every time. I'm not sure why.
"Write a program that reads data into a and b using the pointers x and y. The program then multiplies the value of a by b and stores the results in c using the pointers x, y, and z. Finally, it prints all three variables using the pointers x, y, and z."
Mine let's me type in two numbers, but it returns the number 2 every time. I'm not sure why.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int c;
int b;
int a;
int* x = a;
int* p = b;
int** y = p;
int* q = c;
int** r = q;
int*** z = r;
print (&x, &y);
}
void print (int* x, int** y)
{
scanf("%d %d", &x, &y);
return *x * **y;
}