Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how can i access a direct (absolute, not the offset) memory
address?

here is what i tried:
wrote a program that ask's for an address from the user,
creates a FAR pointer to that adress and shows it. then the
user can increment/decrement the value in that address by
pressing p(inc+) and m(dec-).

NOW, i compiled that program and opened it twice (in 2
different windows) and gave twice the same address to it.
now look what happen - if i change the value in
one "window" of the program, it DOES NOT change in the
other! even if they point to the same address in the memory!

here is the code snippet:
//------------------------------------------------------

#include <stdio.h> //INCLUDE EVERY KNOWN HEADER FILE
#include <conio.h> //FOR ANY CASE...
#include <iostream.h>
#include <dos.h>
#include <process.h>


main()
{
int far *ptr; //FAR POINTER!!!
long address;
char key=0; //A KEY FROM THE KEYBOARD
int temp=0;

clrscr();

cout<<"Enter Address:";
cin>>hex>>address; //GETS THE ADDRESS
clrscr();

(long)ptr=address; temp=*ptr; //PUTS THE ADDRESS IN THE PTR

cout<<"["<<hex<<(unsigned long)ptr<<"]="<<*ptr<<" = "<<
(char)(*ptr);

//SHOWS: [address]=value=ASCII symbol.


while (key!=27) //WHILE YOU DONT PRESS ESC.
{
while(!kbhit()) //WHILE KEY IS NOT PRESSED
{
if (temp!=*ptr) { temp=*ptr; clrscr(); cout<<"["<<hex<<
(unsigned long)ptr<<"]="<<*ptr<<" = "<<(char)(*ptr); };

//IF THE VALUE HAS CHANGED, CLEAR THE SCREEN AND SHOW
//AGAIN

if (key=='p') {key=0; (*ptr)++; } //INCREMENT VALUE
if (key=='m') {key=0; (*ptr)--; } //DEC. VALUE
};
key=getch(); //IF A KEY IS PRESSED, READ IT FROM THE
//KEYBOARD
};
return 0; //IF ESC WAS THE KEY, EXIT THE PROGRAM
}
//---------------------------------------------------------


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More C++ General Interview Questions

Write a program which uses Command Line Arguments

0 Answers  


When do you call copy constructors?

0 Answers  


How to create a reference variable in C++

1 Answers  


What is the difference between public, private, and protected access?

0 Answers  


What is a container class?

0 Answers  


What can I use instead of namespace std?

0 Answers  


What does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)

0 Answers  


Comment on c++ standard exceptions?

0 Answers  


what are the iterator and generic algorithms.

0 Answers  


Is there finally in c++?

0 Answers  


write a programming using for loop in c++ to generate diamond trangel?

1 Answers   NIIT,


Describe functional overloading?

6 Answers   HP,


Categories