| New Reply |
Help with simple pointer program |
Share Thread | Thread Tools |
| Jun17-12, 04:07 PM | #18 |
|
|
Help with simple pointer programI did a printf("%d", &b) And a printf("%d", &*y) And I got back the same answer. |
| Jun17-12, 06:11 PM | #19 |
|
Mentor
|
You don't need the & operator - *y already is an address.
|
| Jun18-12, 09:46 AM | #20 |
|
|
I think I got it. Does this look right?
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;
printf("Enter a value for A: ");
scanf("%d", x);
printf("Enter a value for B: ");
scanf("%d", *y);
*z = *x * **y;
printf("A * B = %d\n", *z);
printf("C = %d\nA = %d\nB = %d", *z, *x, **y);
return 0;
}
|
| Jun18-12, 10:06 AM | #21 |
|
Mentor
|
The problem requirements are satisfied now. Does it give the right results?
|
| New Reply |
| Thread Tools | |
Similar Threads for: Help with simple pointer program
|
||||
| Thread | Forum | Replies | ||
| Simple Java class + driver program help. Program isn't working, but should be. | Programming & Comp Sci | 7 | ||
| Free simple physics program for simple designs | General Engineering | 2 | ||
| an simple program | Programming & Comp Sci | 3 | ||
| Need help with simple C program | Programming & Comp Sci | 4 | ||
| C program: returning a pointer | Introductory Physics Homework | 17 | ||