![]() |
How to compare an address to another address?
How to compare an address to another address and replaces the value stored in that address?
Code:
//This program prints the initialize value and the addresses of the//Input address int temp=0; printf("Please input an address: "); scanf("%d",&temp); *ptr = temp; //Print input printf("Your input: %p\n", *ptr); Code:
printf("Please press the spacebar to continue!!"); |
Re: How to compare an address to another address?
I dont know whether you want to compare the memory location of its value,
if you want to compare the address then the pointer variable itself holds the address it points to since it is numerical we can compare directly. if you want to compare based on its value then dereference the pointer and compare with it, I do not know whether I answered your question , If I am wrong please give me more details and please be specific. |
Re: How to compare an address to another address?
Let us just focus on this..:happy:
Example: Blues inputted by the user Before: Position Value Address 0 1 0022FEA0 1 2 0022FEA4 2 3 0022FEA8 3 4 0022FEAC Please input an address: 0022FEA0 Please input the new value for the address inputted: 7 After Position Value Address 0 7 0022FEA0 1 2 0022FEA4 2 3 0022FEA8 3 4 0022FEAC Please input an address: |
Re: How to compare an address to another address?
this will help you a little bit.
Code:
//This program prints the initialize value and the addresses of the |
Re: How to compare an address to another address?
Thank you!!:happy: but i already resolved the problem..
now may problem is the looping at the last part because when i use switch statement the new value does not appear but when i use if statement the new values print Switch Statement Program Code:
#include <stdio.h>If Statement Program Code:
#include <stdio.h> |
Re: How to compare an address to another address?
try changing
Quote:
Code:
case 1: |
Re: How to compare an address to another address?
Ahh hahaha..now I got it because whenever i choose the number 1 the program resets..
Thanks alot virxen |
| All times are GMT +5.5. The time now is 02:47. |