<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Fri May 24, 2013 8:40 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Fri May 24, 2013 8:40 pm</pubDate>
  <lastBuildDate>Fri May 24, 2013 8:40 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Memory Manipulation in C</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=11013#11013</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=115'&gt;Gordon&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Oct 28, 2005 5:05 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Because that would cause a segmentation fault, your program would immediately quit and, depending on how your system is set up, would produce a core dump to help with tracing the problem.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=11013#11013</comments>
                                        <author>Gordon</author>
                                        <pubDate>Fri Oct 28, 2005 5:05 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=11013#11013</guid>
                                      </item>
                                      <item>
                                        <title>Re: Memory Manipulation in C</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=10966#10966</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=148'&gt;tedius&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Oct 28, 2005 9:32 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Yes, you can move the pointer to any point in you allocated space to read write. But you must be careful that you don't end up going off the end of memory that you have allocated.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=10966#10966</comments>
                                        <author>tedius</author>
                                        <pubDate>Fri Oct 28, 2005 9:32 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=10966#10966</guid>
                                      </item>
                                      <item>
                                        <title>Re: Memory Manipulation in C</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=10907#10907</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=3431'&gt;www.bnp.org.uk&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Oct 27, 2005 1:51 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Thanks. I have been reading up on pointers via google and understand what you have typed.&lt;br /&gt;
&lt;br /&gt;
So now that I have *pChar, can I point it anywhere inside this allocated memory, say for example pChar = pChar + 0x100 and then *pChar = 0xff?&lt;br /&gt;
&lt;br /&gt;
I want access to the memory as you would get in assembler.&lt;br /&gt;
&lt;br /&gt;
Cheers.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=10907#10907</comments>
                                        <author>www.bnp.org.uk</author>
                                        <pubDate>Thu Oct 27, 2005 1:51 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=10907#10907</guid>
                                      </item>
                                      <item>
                                        <title>Re: Memory Manipulation in C</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=10840#10840</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=148'&gt;tedius&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Oct 26, 2005 2:34 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      You will have to cast the point first.  You should then be able to use it as normal.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
/* malloc the memory */&lt;br /&gt;
void *pVoid = malloc&amp;#40;1024&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
/* Cast the pointer to something we can use */&lt;br /&gt;
char *pChar = &amp;#40;char *&amp;#41; pVoid;&lt;br /&gt;
&lt;br /&gt;
/* write to memory */&lt;br /&gt;
strcpy&amp;#40;pChar, &amp;quot;Hello World&amp;quot;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
/* Read from memory */&lt;br /&gt;
printf&amp;#40;&amp;quot;%s\n&amp;quot;, pChar&amp;#41;;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
I hope that makes sence.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=10840#10840</comments>
                                        <author>tedius</author>
                                        <pubDate>Wed Oct 26, 2005 2:34 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=10840#10840</guid>
                                      </item>
                                      <item>
                                        <title>Memory Manipulation in C</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=10726#10726</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=3431'&gt;www.bnp.org.uk&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Oct 25, 2005 12:27 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hi&lt;br /&gt;
&lt;br /&gt;
I am writing a program in C and need to know how I can directly access say 1mb of memory allocated via malloc.&lt;br /&gt;
&lt;br /&gt;
Within this 1mb I need to be able to read and write individual bytes and words.&lt;br /&gt;
&lt;br /&gt;
Prototype: void *malloc(size_t size);&lt;br /&gt;
&lt;br /&gt;
malloc returns a pointer of type void, which is a pointer that points to anything i.e. it doesn't have a type like char, short int, int etc. Apparently it is not possible to get a value at the address of a void pointer presumably because it is not known what type that value would be.&lt;br /&gt;
&lt;br /&gt;
So how do I read and write bytes (chars) and words (short ints)?&lt;br /&gt;
&lt;br /&gt;
Regards</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=10726#10726</comments>
                                        <author>www.bnp.org.uk</author>
                                        <pubDate>Tue Oct 25, 2005 12:27 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=10726#10726</guid>
                                      </item></channel></rss>