<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: file read-write operation&#8230;unexpected output&#8230; plz explain&#8230;</title>
	<atom:link href="https://www.emblogic.com/blog/08/file-read-write-operation-unexpected-output-plz-explain/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.emblogic.com/blog/08/file-read-write-operation-unexpected-output-plz-explain/</link>
	<description>Embedded System and ARM Training</description>
	<lastBuildDate>Mon, 07 Oct 2013 04:00:03 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>By: rahul1989</title>
		<link>https://www.emblogic.com/blog/08/file-read-write-operation-unexpected-output-plz-explain/#comment-1384</link>
		<dc:creator><![CDATA[rahul1989]]></dc:creator>
		<pubDate>Sun, 19 Aug 2012 02:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://emblogic.org/blog/?p=4873#comment-1384</guid>
		<description><![CDATA[char ch = 144
giving negative integer value because overflow had started]]></description>
		<content:encoded><![CDATA[<p>char ch = 144<br />
giving negative integer value because overflow had started</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rahul1989</title>
		<link>https://www.emblogic.com/blog/08/file-read-write-operation-unexpected-output-plz-explain/#comment-1383</link>
		<dc:creator><![CDATA[rahul1989]]></dc:creator>
		<pubDate>Sun, 19 Aug 2012 02:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://emblogic.org/blog/?p=4873#comment-1383</guid>
		<description><![CDATA[look your code carefully.
you have done big mistakes.
 ch=144
in this line you are trying to enter the multiple character in a single character.
char is 1 byte data type.
to print desired result you need to take 144 as a string.
one another method that if you take ch as int type instead of char then your problem may resolve.
i am giving you 1 e.g..



void main()
{
int ch=144;
int str;
int fd;
fd=open(&quot;transfer.txt&quot;,O_WRONLY&#124;O_CREAT&#124;O_TRUNC);
if(fd&lt;0)
{
perror(&quot;fault\n&quot;);
exit(1);
}
write(fd,&amp;ch,sizeof(int));
close(fd);
fd=open(&quot;transfer.txt&quot;,O_RDONLY);
read(fd,&amp;str,sizeof(int));
printf(&quot;%d\n&quot;,str);
close(fd);
}]]></description>
		<content:encoded><![CDATA[<p>look your code carefully.<br />
you have done big mistakes.<br />
 ch=144<br />
in this line you are trying to enter the multiple character in a single character.<br />
char is 1 byte data type.<br />
to print desired result you need to take 144 as a string.<br />
one another method that if you take ch as int type instead of char then your problem may resolve.<br />
i am giving you 1 e.g..</p>
<p>void main()<br />
{<br />
int ch=144;<br />
int str;<br />
int fd;<br />
fd=open(&#8220;transfer.txt&#8221;,O_WRONLY|O_CREAT|O_TRUNC);<br />
if(fd&lt;0)<br />
{<br />
perror(&quot;fault\n&quot;);<br />
exit(1);<br />
}<br />
write(fd,&amp;ch,sizeof(int));<br />
close(fd);<br />
fd=open(&quot;transfer.txt&quot;,O_RDONLY);<br />
read(fd,&amp;str,sizeof(int));<br />
printf(&quot;%d\n&quot;,str);<br />
close(fd);<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
