Writing to Specific Locations

This is a discussion on Writing to Specific Locations within the C Programming forums, part of the General Programming Boards category; How do I load address location 7890 with value A1B2 in C? Does it require pointers?...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    2

    Question Writing to Specific Locations

    How do I load address location 7890 with value A1B2 in C?
    Does it require pointers?

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Why the heck would you need to write to a specific location?

  3. #3
    Registered User SavesTheDay's Avatar
    Join Date
    Jan 2002
    Posts
    77
    Captain Penguin Why the heck would you need to write to a specific location?
    that's one of the dumbest responses I've ever heard around here....

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    >>How do I load address location 7890 with value A1B2 in C?

    int *pointy = (int *)0x7890;

    or alternatively...

    &pointy = 0x7890;

    >>that's one of the dumbest responses I've ever heard around here....<<

    Why yes...yes it is.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Originally posted by SavesTheDay


    that's one of the dumbest responses I've ever heard around here....
    Sigh.

    My train of thought was "well why would you need to write to a specific memory address? For that information to be of value, it would have to be assigned to a variable, right? Thus why not just create a variable at a random location and use a pointer to that one. Whats the point of a specific locale?"

    Apparantly I am wrong, but I had no clue since my C skills are not very advanced. Hell, all I know I learned from "C for Dummies"

    I'd appreciate a more constructive response than simply insinuating that I'm a dumbass (regarldess of the facts). e.g., you could have told me why anyone would want to write to a specific memory location, preventing further dumbass comments on the subject.
    Last edited by Captain Penguin; 02-14-2002 at 10:17 PM.

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    2
    Thanks Ken.

    I guessed at the second method , but was unsure.
    The first method I'll have to study.
    I'm learning C and there are (as I'm sure you're aware)
    some obscure things that are difficult to grasp. Getting
    a memory location is easy, the other way around is just
    not spelled out in the texts that I have. This was the first
    question that I could not find an answer to by searching
    through this forum. What would you guys recommend as
    a reference to find these hidden gems of programming?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-20-2008, 09:57 AM
  2. writing to a binary file
    By Inver28 in forum C Programming
    Replies: 4
    Last Post: 03-02-2008, 02:36 AM
  3. Searching for specific string using fstream
    By comwiz in forum C++ Programming
    Replies: 2
    Last Post: 07-18-2007, 04:37 AM
  4. writing to certain locations.
    By epidemic in forum C++ Programming
    Replies: 2
    Last Post: 12-19-2006, 12:12 PM
  5. Very slow file writing of 'fwrite' function in C
    By scho in forum C Programming
    Replies: 6
    Last Post: 08-03-2006, 03:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21