LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-13-2010, 12:50 AM   #1
cvr
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Rep: Reputation: 0
write a value from a specific mem loc in c


Hi


Can anyone help me ,how to write a value to a specific memory location in C language and how to access the same value ?
I am trying the same on fedora linux and i am trying to write the value to the 32-bit adress.

Please share if you have an example code of the same..for better understanding purpose..

Thanks in advance..........BYE

Last edited by cvr; 07-13-2010 at 05:44 AM. Reason: Write a value to a specific mem loc in c language
 
Old 07-13-2010, 08:47 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Well, I guess like with every programming question here I'd have to ask what have you tried so far. But, then I also have to ask why you would ever attempt this, knowing fully well that the result will be a segmentation fault ...
 
Old 07-13-2010, 10:11 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by cvr View Post
how to write a value to a specific memory location in C language
You should explain why you want to do that.

You have asked the kind of question that usually implies a more fundamental misunderstanding. So a direct answer to the question would be useless.

Also, are you aware of the difference between physical "memory locations" and virtual "memory locations"?

Almost everything any program does in Linux deals with virtual locations. It is trivial to access (read or write) a specific virtual location in C. But there is almost no possibility that you have a constructive purpose in doing so (as opposed to thinking you want to do so because you misunderstand something more fundamental).

A valid reason to want to access a specific physical location is also unlikely, but not as unlikely. It is harder to access a specific physical location. You need root privileges and then use either the /proc filesystem or other methods of requesting the access through the OS. To give any constructive instructions, we would need to know what/why you actually want to access.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] write file to a specific sector wiener Linux - General 8 06-28-2010 04:59 PM
How to write to a file with specific indentation through php ? wrapster Programming 1 12-12-2008 05:09 AM
write text to specific location in file mcbenus Linux - Desktop 3 02-28-2008 06:40 AM
Evolution: How to CC each time I write to a specific person? guarriman Linux - Software 0 12-12-2006 04:34 AM
RPM: Copying files to desired loc using %install directive raqueeb Linux - Software 0 02-12-2004 10:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration