#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Requesting All for Completing this Small Code using mmap()


    -purpose is to just Print the first 'memory address' to a Text File:
    /home/z/test.txt
    Simple
    Please Fill In!!!

    #include <stdio.h>
    int main()
    {


    }
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    In your previous post you said you wanted to learn.

    So far, all you've managed to do is read my message to figure out that mmap is the thing to use, and then dumped a laughably empty main as your 'best attempt'.

    The fact that you couldn't even be arsed to scroll down to the end of the manual page I gave you to see an actual worked example means you're not worth the effort.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0
    You got it all wrong. Im not here to learn how to program in deep,
    Rather Im a Neuroscience Research Scholar Finding a way to mimik the Modality memory associations done by Brain using C!
    I have a basic programing knowledge and
    I just need the Memory Address to the begining of a File stored in HardDisk.
    It would be really Helpful if you could please write down a simplest code for that purpose....
    Thankyou
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,171
    Rep Power
    2222
    Originally Posted by zacless
    ... I just need the Memory Address to the begining of a File stored in HardDisk.
    Then Read The Manual! (RTFM!). The man page for mmap tells you what you are asking for. salem pointed you right to it, and yet you want us to spoon-feed it to you instead.

    All my childhood I had been told that college isn't for learning, but rather for learning how to learn. That involves developing scholarship, which includes learning how to do research. You claim to be a scholar and yet you do not know how to do the most basic form of research?

    RTFM!
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,889
    Rep Power
    481
    Does describing a task as "simple" not mean that the utterer can solve that task?
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,111
    Rep Power
    1803
    The answer from me to your previous question includes links to pages that include examples.

    Your requirement "to just Print the first 'memory address' to a Text File" is ambiguous at best. With a memory mapped file, you simply have a pointer which you can use to read and write as if the file were memory - as an array of whatever data type you choose.

    This is not a free programming service, it is a forum for those interested in programming. Learn something.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0
    Are there electronic Devices that work by storing and directly accessing raw data?
    I think Computers dont work that way because they are designed as multipurpose platform, to be able to abruptly change and run distinct programs and for data security.

    But what if a Device is hardwired to run only one program in a steriotyped way, i.e store data and only access that data.
    can u suggest any Class of Devices that might work that way?

    and please suggest which area of computer science deals with this subject of memory, storages and how it all works.

    Comments on this post

    • clifford disagrees : Sounds like a re-worded homework question to me. Perhaps you are thinking of [i]embedded systems[/i].
  14. #8
  15. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    Why does it seem like all your posts are written by different people? You're all over the place!

    > Rather Im a Neuroscience Research Scholar Finding a way to mimik the Modality memory associations done by Brain using C!
    Well if you're trying to do this in C, then finding the address of a file is the least of your worries. C is a very low level language, which means you need a lot of code to actually get anything useful.

    And why the address of a file? It seems an awfully specific statement when you have no idea about the rest of system you're proposing. If all you really want is a number associated with some text, then
    Code:
    char *data[] = {
        "this",
        "is",
        "some",
        "kind",
        "of",
        "data"
    };
    simulates the same thing.
    You take an integer (say 2 - call it an address), and you get some data ("some" - call it a filename, or even the content of a file).


    > Im not here to learn how to program in deep,
    > I have a basic programing knowledge and
    Since you're never actually going to write the code, why don't you just state that every file has a unique address on the file system (which is true), and leave it at that.


    > I just need the Memory Address to the begining of a File stored in HardDisk.
    Now that I think about it some more, perhaps all you need is the stat() function (look it up, you've already been shown how) and print the inode number of the file. Each file (for your purposes at least) has a unique inode value.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo