Thread: varible declartion

  1. #1
    Registered User
    Join Date
    May 2002

    varible declartion


    here is my problem

    char far s,s2;

    what is far in the above statement.
    and how it differs with ordinary one.

    thank u

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Bangalore, India
    In DOS, far pointers are used to access memory outside it's normal reach (SEGMENT). It access the memory in the fashion SEGMENT:OFFSET.
    Example, to access the Video RAM, which is located at: B800, you would decalre a far pointer like:

    unsigned char far *addr = 0xB8000000;
    The leading zeroes is the OFFSET in the SEGMENT. Thus, a far pointer has two parts, SEGMENT:OFFSET, whose physical address is got by:

    which creates a 20bit address. Thus, the reach is till 1MB with this kind of a pointer.

  3. #3
    Registered User
    Join Date
    Jul 2002

    far & huge pointer

    for every c program in execution, there is sth called address space where memory space is allocated for ur variables..( stack , heap, etc..) are located..
    every program has its own address space..which is 64k.. and one program cannot normally access data from another address space (there are ways to do this also..) ..
    for accessing 64k u dont ned need more than 2 bytes (16 bits coz 2^16= 64k )...
    so a pointer is of 2 bytes.
    but if u want to access data outside the address space then u need bigger pointers. so far and huge pointers are used here. they have a size of 4 bytes and can access data from anywhere in the hard-disk. (i dunno how..tacitly assumed)

    u should ahve hearsd that c can be used to write viruses and all tht stuff. so here u r trying to rwite into address space of another program.. here u have to use far pointers.

    hope ur puzzle is solved.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    Interesting. How might you output the contents graphically?(what interrupt?)

    Had fun displaying the values, tho...

    int main()
    unsigned x = 0xB8000000;
    unsigned char far *addr;
    *addr = x;
    unsigned char far *a;
    for (a = addr; a != NULL; a++)
      printf(":: <Addr>: [Hex]-  %p  [Int]- %6i       <Contents>: %4i     \n"
              , a, (int)a, (int)*a);
    return 0; 
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Turning a varible into a global.
    By Queatrix in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2005, 06:58 PM
  2. accessing varible in a c++ class
    By jccharl in forum C++ Programming
    Replies: 1
    Last Post: 03-10-2004, 03:01 PM
  3. Randomize Varible
    By Hussa in forum C++ Programming
    Replies: 5
    Last Post: 01-10-2003, 10:12 AM
  4. Array Varible
    By Jonh in forum C++ Programming
    Replies: 4
    Last Post: 01-09-2003, 06:31 PM
  5. Varible is different once returned.
    By epoch in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2003, 02:45 AM