<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4825298097849543272</id><updated>2012-01-28T01:16:09.815-08:00</updated><title type='text'>aarklon-news</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default?start-index=101&amp;max-results=100'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>298</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-706004731741280609</id><published>2009-11-15T00:22:00.001-08:00</published><updated>2009-11-15T00:24:54.573-08:00</updated><title type='text'>power pc 7448 sbc board</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/Sv-6dAVuDxI/AAAAAAAABmg/WmUFawhXhYY/s1600-h/Image0112.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 240px; height: 320px;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/Sv-6dAVuDxI/AAAAAAAABmg/WmUFawhXhYY/s320/Image0112.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5404243085337956114" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;_uacct = "UA-4163235-1";&lt;br /&gt;urchinTracker();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-706004731741280609?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/706004731741280609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=706004731741280609' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/706004731741280609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/706004731741280609'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/11/power-pc-7448-sbc-board.html' title='power pc 7448 sbc board'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/Sv-6dAVuDxI/AAAAAAAABmg/WmUFawhXhYY/s72-c/Image0112.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8979350228200891106</id><published>2009-07-12T08:22:00.001-07:00</published><updated>2009-07-12T08:24:56.735-07:00</updated><title type='text'>short- circuiting example</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SloAJ-BmagI/AAAAAAAABUE/AgtfsYkvO4M/s1600-h/short-circuiting.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 280px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SloAJ-BmagI/AAAAAAAABUE/AgtfsYkvO4M/s320/short-circuiting.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5357594877979159042" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8979350228200891106?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8979350228200891106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8979350228200891106' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8979350228200891106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8979350228200891106'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/07/short-circuiting-example.html' title='short- circuiting example'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/SloAJ-BmagI/AAAAAAAABUE/AgtfsYkvO4M/s72-c/short-circuiting.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8663655548897719405</id><published>2009-06-25T11:06:00.000-07:00</published><updated>2009-06-25T11:07:08.198-07:00</updated><title type='text'>Symmetric Key Encryption</title><content type='html'>The most basic form of encryption is symmetric key encryption, so named because both the sender and the receiver of the data use the same key to encrypt and decrypt the data. The problem with symmetric key encryption is that you must have a secure way to transport the encryption key to individuals you wish to exchange data with. If you do not use a secure method to send the key to a recipient, someone may intercept the key. This makes encryption useless, because now the interceptor&lt;br /&gt;can decrypt the data knowing the key. In addition, if you are using encryption techniques for multiple recipients, you may not want one person to have access to another’s data. Now you must keep multiple single keys per person, which can become extremely cumbersome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8663655548897719405?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8663655548897719405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8663655548897719405' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8663655548897719405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8663655548897719405'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/06/symmetric-key-encryption.html' title='Symmetric Key Encryption'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7462096667290927270</id><published>2009-06-25T11:00:00.001-07:00</published><updated>2009-06-25T11:00:43.458-07:00</updated><title type='text'>Stream Cipher</title><content type='html'>Stream cipher algorithms encrypt data one bit at a time. Plain text bits are converted into encrypted cipher text. This method is usually not as secure as block cipher techniques, but it generally executes faster. In addition, the cipher text is always the same size as the original plain text and is less prone to errors. If an error occurs during the encryption process, usually this affects only a single bit instead of the whole string. In contrast, when block ciphers contain errors, the entire block becomes unintelligible.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7462096667290927270?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7462096667290927270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7462096667290927270' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7462096667290927270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7462096667290927270'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/06/stream-cipher.html' title='Stream Cipher'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-265581507614940276</id><published>2009-06-25T10:58:00.000-07:00</published><updated>2009-06-25T10:59:20.519-07:00</updated><title type='text'>block cipher</title><content type='html'>Instead of encrypting a bit at a time, block cipher algorithms encrypt data in blocks. Block ciphers also have more overhead than stream ciphers, which is provided separately depending on the implementation and the block size that can be modified (the most common size being 64 bits). Because it handles encryption at a higher level, it is generally more secure. The downside is that the execution takes longer. Numerous block cipher options  are available, such as Electronic Codebook (ECB), Cipher Block Chaining (CBC), Cipher Feedback (CFB), and Output Feedback Mode (OFB).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-265581507614940276?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/265581507614940276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=265581507614940276' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/265581507614940276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/265581507614940276'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/06/block-cipher.html' title='block cipher'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7101119550832148666</id><published>2009-06-25T10:54:00.000-07:00</published><updated>2009-06-25T10:55:25.425-07:00</updated><title type='text'>D.E.S</title><content type='html'>The Data Encryption Standard (DES) was created and standardized by IBM in 1977. It is a 64-bit block symmetric algorithm and is specified in the ANSI X3.92 and X3.106 standards for both enciphering and deciphering operations, which are based on a binary number. In addition, the National Security Agency (NSA) uses it as the standard for all government organizations. There currently exist 72 quadrillion (72,000,000,000,000,000) encryption keys for DES, in which a key is chosen at  random. DES uses a block cipher methodology to apply a 56-bit symmetric key to each 64-bit block. An additional form of DES, known as triple DES, applies three keys in succession to each block.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7101119550832148666?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7101119550832148666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7101119550832148666' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7101119550832148666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7101119550832148666'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/06/des.html' title='D.E.S'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-3750689145016091891</id><published>2009-03-15T11:32:00.000-07:00</published><updated>2009-04-30T04:59:35.270-07:00</updated><title type='text'>The dining philosophers</title><content type='html'>&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/P-8ceLiMuEA&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/P-8ceLiMuEA&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite, Generated: 2009-04-30 7:56:36  --&gt;&lt;br /&gt;&lt;script type="text/javascript" src="http://ads.adbrite.com/mb/text_group.php?sid=1151588&amp;br=1"&gt;&lt;/script&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-3750689145016091891?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/3750689145016091891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=3750689145016091891' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3750689145016091891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3750689145016091891'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/03/dining-philosophers.html' title='The dining philosophers'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-3317418215134807622</id><published>2009-01-20T09:51:00.000-08:00</published><updated>2009-01-20T09:52:31.984-08:00</updated><title type='text'>Binky The Pointer fun Video</title><content type='html'>&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/f-pJlnpkLp0&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/f-pJlnpkLp0&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-3317418215134807622?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/3317418215134807622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=3317418215134807622' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3317418215134807622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3317418215134807622'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/01/binky-pointer-fun-video.html' title='Binky The Pointer fun Video'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1027206081399488987</id><published>2009-01-11T22:10:00.000-08:00</published><updated>2009-01-11T22:39:19.484-08:00</updated><title type='text'>strace,  ltrace, mtrace</title><content type='html'>&lt;span style="font-weight:bold;"&gt;strace&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; the strace utility traces all the system calls and signals for the specified program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ltrace&lt;/span&gt;&lt;br /&gt; it traces calls to the dynamic libraries&lt;br /&gt;&lt;br /&gt;Ex:-&lt;br /&gt;&lt;br /&gt; user@ubuntu:~$ ltrace -t ./hello1&lt;br /&gt;11:39:31 __libc_start_main(0x8048374, 1, 0xbf804e64, 0x80483e0, 0x80483d0 &lt;unfinished ...&gt;&lt;br /&gt;11:39:31 puts("./hello1"./hello1&lt;br /&gt;)                                                                        = 9&lt;br /&gt;11:39:31 puts("Hello World....."Hello World.....&lt;br /&gt;)                                                                = 17&lt;br /&gt;11:39:31 +++ exited (status 0) +++&lt;br /&gt; &lt;br /&gt;see man ltrace for more details&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;mtrace&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;the mtrace utility is used to trace the use of dynamic memory by a program. it keeps track of the memory allocation and de- allocation operations; it traces memory leaks.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; To pin down all potential memory leak areas in your program, you will have to perform the following sequence of steps&lt;br /&gt;&lt;br /&gt;1) include the mcheck.h file in the program and place an mtrace() function call at the start of the program .&lt;br /&gt;&lt;br /&gt;2) then specify the name of the file, in which memory checking resulots should be stored, by exporting the name into an environment variable, as in the following example&lt;br /&gt;&lt;br /&gt; export MALLOC_TRACE=mem.log&lt;br /&gt;&lt;br /&gt;running the program now will register all memory alllocating and freeing operations in  the mem.log file. Finally, the mtrace utility is called as follows&lt;br /&gt;&lt;br /&gt;mtrace your_prog $MALLOC_TRACE&lt;br /&gt;&lt;br /&gt;The produced information is examined for records, in which memory was allocated but not freed. For the described procedure to succeed,the program under investigation must terminate normally&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1027206081399488987?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1027206081399488987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1027206081399488987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1027206081399488987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1027206081399488987'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/01/strace-ltrace-mtrace.html' title='strace,  ltrace, mtrace'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1260971752911227661</id><published>2009-01-11T21:43:00.000-08:00</published><updated>2009-01-11T22:05:15.487-08:00</updated><title type='text'>ldd, Strings and hexdump utilities</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Ldd &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;the ldd utility displays all the shared libraries required by each program &lt;br /&gt;&lt;br /&gt;Ex:- ldd ./myprogram&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;strings&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; the strings utility displays strings of printable ASCII characters in a file longer than four characters.&lt;br /&gt;&lt;br /&gt;Ex:-&lt;br /&gt;&lt;br /&gt;user@ubuntu:~$ strings ./hello1&lt;br /&gt;/lib/ld-linux.so.2&lt;br /&gt;__gmon_start__&lt;br /&gt;libc.so.6&lt;br /&gt;_IO_stdin_used&lt;br /&gt;puts&lt;br /&gt;__libc_start_main&lt;br /&gt;GLIBC_2.0&lt;br /&gt;PTRh&lt;br /&gt;QVht&lt;br /&gt;[^_]&lt;br /&gt;Hello World.....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Hexdump and od&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The hexdump  utility displays the contents of the specified file  in the deciomal (-d), hexadecimal (-x), octal (-b) and ASCII (-c) modes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ex:- &lt;br /&gt;         hexdump -c ./yourprog&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The od utility is analogous to the hexdump utility.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1260971752911227661?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1260971752911227661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1260971752911227661' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1260971752911227661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1260971752911227661'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2009/01/ldd-strings-and-hexdump-utilities.html' title='ldd, Strings and hexdump utilities'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7819239879158757619</id><published>2008-12-24T00:42:00.000-08:00</published><updated>2009-01-11T21:32:29.146-08:00</updated><title type='text'>Nm ,Strip and Size utilities</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Nm utility&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The nm utility outputs to the standard device a table of symbols for each file specified in the argument list.symbol tables arec used to debug applications. The utility displays the name of each symbol and in formation about its type: a data symbol(a variable), a program symbol (a label or a function name), and so on.&lt;br /&gt;&lt;br /&gt;Ex:- &lt;br /&gt;&lt;br /&gt;     nm ./hello1 &lt;br /&gt;./hello1:&lt;br /&gt;080494bc d _DYNAMIC&lt;br /&gt;08049590 d _GLOBAL_OFFSET_TABLE_&lt;br /&gt;0804848c R _IO_stdin_used&lt;br /&gt;         w _Jv_RegisterClasses&lt;br /&gt;080494ac d __CTOR_END__&lt;br /&gt;080494a8 d __CTOR_LIST__&lt;br /&gt;080494b4 d __DTOR_END__&lt;br /&gt;080494b0 d __DTOR_LIST__&lt;br /&gt;080484a4 r __FRAME_END__&lt;br /&gt;080494b8 d __JCR_END__&lt;br /&gt;080494b8 d __JCR_LIST__&lt;br /&gt;080495b4 A __bss_start&lt;br /&gt;080495a8 D __data_start&lt;br /&gt;08048440 t __do_global_ctors_aux&lt;br /&gt;08048320 t __do_global_dtors_aux&lt;br /&gt;080495ac D __dso_handle&lt;br /&gt;         w __gmon_start__&lt;br /&gt;0804843a T __i686.get_pc_thunk.bx&lt;br /&gt;080494a8 d __init_array_end&lt;br /&gt;080494a8 d __init_array_start&lt;br /&gt;080483d0 T __libc_csu_fini&lt;br /&gt;080483e0 T __libc_csu_init&lt;br /&gt;         U __libc_start_main@@GLIBC_2.0&lt;br /&gt;080495b4 A _edata&lt;br /&gt;080495b8 A _end&lt;br /&gt;0804846c T _fini&lt;br /&gt;08048488 R _fp_hw&lt;br /&gt;08048274 T _init&lt;br /&gt;080482f0 T _start&lt;br /&gt;080495b4 b completed.5843&lt;br /&gt;080495a8 W data_start&lt;br /&gt;08048350 t frame_dummy&lt;br /&gt;08048374 T main&lt;br /&gt;080495b0 d p.5841&lt;br /&gt;         U puts@@GLIBC_2.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Strip utility&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;when a program has been debugged, the symbol table can be deleted from it. This is accomplished using the strip utility.&lt;br /&gt;&lt;br /&gt;ex:- strip ./your_prog&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Size&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; The size utility displays section sizes in each of the specified files. By default, the size of only the command(.text) , data (.data), and un -initialized data (.bss) sections and the total size of these sections are listed in the decimal and hexadecimal format.&lt;br /&gt;&lt;br /&gt;to list the sizes of all sections in the file, the -A flag is used.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ex:- &lt;br /&gt;&lt;br /&gt;   size ./hello1&lt;br /&gt;   text    data     bss     dec     hex filename&lt;br /&gt;   852     268       4    1124     464 ./hello1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ex:- &lt;br /&gt;&lt;br /&gt;    size -A ./hello1&lt;br /&gt;./hello1  :&lt;br /&gt;section           size        addr&lt;br /&gt;.interp             19   134512916&lt;br /&gt;.note.ABI-tag       32   134512936&lt;br /&gt;.hash               40   134512968&lt;br /&gt;.gnu.hash           32   134513008&lt;br /&gt;.dynsym             80   134513040&lt;br /&gt;.dynstr             74   134513120&lt;br /&gt;.gnu.version        10   134513194&lt;br /&gt;.gnu.version_r      32   134513204&lt;br /&gt;.rel.dyn             8   134513236&lt;br /&gt;.rel.plt            24   134513244&lt;br /&gt;.init               48   134513268&lt;br /&gt;.plt                64   134513316&lt;br /&gt;.text              380   134513392&lt;br /&gt;.fini               28   134513772&lt;br /&gt;.rodata             25   134513800&lt;br /&gt;.eh_frame            4   134513828&lt;br /&gt;.ctors               8   134517928&lt;br /&gt;.dtors               8   134517936&lt;br /&gt;.jcr                 4   134517944&lt;br /&gt;.dynamic           208   134517948&lt;br /&gt;.got                 4   134518156&lt;br /&gt;.got.plt            24   134518160&lt;br /&gt;.data               12   134518184&lt;br /&gt;.bss                 4   134518196&lt;br /&gt;.comment           294           0&lt;br /&gt;.debug_aranges     112           0&lt;br /&gt;.debug_pubnames     64           0&lt;br /&gt;.debug_info        770           0&lt;br /&gt;.debug_abbrev      215           0&lt;br /&gt;.debug_line        358           0&lt;br /&gt;.debug_frame        80           0&lt;br /&gt;.debug_str         187           0&lt;br /&gt;.debug_loc          67           0&lt;br /&gt;.debug_ranges       64           0&lt;br /&gt;Total             3383&lt;br /&gt;&lt;br /&gt;NB:- verified on gcc version 4.2.4&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7819239879158757619?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7819239879158757619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7819239879158757619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7819239879158757619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7819239879158757619'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/12/kernel-protection-against-syn-flooding.html' title='Nm ,Strip and Size utilities'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-9092632877387098723</id><published>2008-12-23T21:06:00.000-08:00</published><updated>2008-12-23T21:09:23.832-08:00</updated><title type='text'>polynomial accumalation</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;the following is what i have seen about polynomial accumulation&lt;br /&gt;&lt;br /&gt;http://s529.photobucket.com/albums/dd339/aarklon/?action=view&amp;current=Screenshot4.png&lt;br /&gt;&lt;br /&gt;  in the lecture by naveen garg&lt;br /&gt;&lt;br /&gt;now my question is on what basis/grounds the values 33,37,39 or 41 is chosen so that it gives only atmost 6 collisions on a vocabulary of 50,000 English words ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Tobby&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Educated guess, trial and error? Or you could use a tool like gperf to construct a perfect hashing function for a predetermined vocabulary: http://www.gnu.org/software/gperf/ &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;_uacct = "UA-4163235-1";&lt;br /&gt;urchinTracker();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-9092632877387098723?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/9092632877387098723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=9092632877387098723' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9092632877387098723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9092632877387098723'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/12/polynomial-accumalation.html' title='polynomial accumalation'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1943364032435152616</id><published>2008-12-15T20:22:00.001-08:00</published><updated>2008-12-15T20:24:46.435-08:00</updated><title type='text'>stream cipher</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/SUctKqSgV7I/AAAAAAAAAyE/euUXlOzmfdc/s1600-h/wswpf_11.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 177px;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/SUctKqSgV7I/AAAAAAAAAyE/euUXlOzmfdc/s320/wswpf_11.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5280238749289043890" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source cisco&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1943364032435152616?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1943364032435152616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1943364032435152616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1943364032435152616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1943364032435152616'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/12/stream-cipher.html' title='stream cipher'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/SUctKqSgV7I/AAAAAAAAAyE/euUXlOzmfdc/s72-c/wswpf_11.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6517523294658411645</id><published>2008-10-19T09:22:00.000-07:00</published><updated>2008-10-29T22:09:21.490-07:00</updated><title type='text'>"C A Dying Skill"</title><content type='html'>&lt;span style="font-weight:bold;"&gt;linvin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Came across this article in the ComputerWorld website which has included C in the top ten dying languages.&lt;br /&gt;&lt;br /&gt;The top 10 dead (or dying) computer skills&lt;br /&gt;http://www.computerworld.com/action/article.do?command=viewArticleBas...&lt;br /&gt;&lt;br /&gt;To quote from the article&lt;br /&gt;&lt;br /&gt;&lt;snip&gt;&lt;br /&gt;6. C programming&lt;br /&gt;As the Web takes over, C languages are also becoming less relevant,according to Padveen. "C++ and C Sharp are still alive and kicking, but try to find a basic C-only programmer today, and you'll likely find a guy that's unemployed and/or training for a new skill," he&lt;br /&gt;says."&lt;br /&gt;&lt;snip&gt;&lt;br /&gt;&lt;br /&gt;I personally feel the authors have done very little research on evaluating C to relegate it to a obsolete langauage. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Linny said:&lt;br /&gt;&lt;br /&gt;&gt; Came across this article in the ComputerWorld website which has&lt;br /&gt;&gt; included C in the top ten dying languages.&lt;br /&gt;&lt;br /&gt;If you can't at least /read/ C, you're cutting yourself off from the huge amount of knowledge to be found in the literature, because so much of it is expressed in C. And if you can't /write/ C, you're not going to be a great deal of use in an embedded systems shop. Nor will you be as employable to a Unix site as someone who /can/ write C.&lt;br /&gt;&lt;br /&gt;Like all such lists, it seems to have been put together by someone whose expertise rests not so much in what he's listing as in his ability to make lists. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;blufox&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt; To quote from the article&lt;br /&gt;&lt;br /&gt;&gt; &lt;snip&gt;&lt;br /&gt;&gt; 6. C programming&lt;br /&gt;&gt; As the Web takes over, C languages are also becoming less relevant,&lt;br /&gt;&gt; according to Padveen. "C++ and C Sharp are still alive and kicking,&lt;br /&gt;&gt; but try to find a basic C-only programmer today, and you'll likely&lt;br /&gt;&gt; find a guy that's unemployed and/or training for a new skill," he&lt;br /&gt;&gt; says."&lt;br /&gt;&lt;br /&gt;The guy is either suffering from brain tumour/down's syndrome or is severly mentally retarted.&lt;br /&gt;Did he even program in C? &lt;br /&gt;&lt;br /&gt;All crap stuff from some luser.How about embedded world, go write programs in .NET or Java for it.&lt;br /&gt;Kernels still use C. And yes he doesn't find some basic C-only programmer because they are&lt;br /&gt;not interested in being spotted by a braindead random article write who has no knowledge of C.&lt;br /&gt;&lt;br /&gt;huh...C is dead, utter nonsense.&lt;br /&gt;&lt;br /&gt;And yes maybe he went to Redmond to figure out that they program their&lt;br /&gt;OS in .NET and what not which is not *C*.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Malcom mclean&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There's a bit of truth in it. If you just know C and no other language, and you don't have any other skill, such as a knowledge of biochemistry, then opportunities for employment will be limited.&lt;br /&gt;&lt;br /&gt;However C is the default language for specifying algorithms. The Graphics Gems series invited submissions in any language, and every single routine submitted was in C.&lt;br /&gt;&lt;br /&gt;There are way too many programming languages. I've got perl scripts, shell scripts, C and C++, Fortran and Java programs, all of which do essentially the same things - iterate over datasets in loops, move information from one palce to another, and do a few arithemtical calculations. There's no real reason they couldn't all be written in a common language, but C graphics won't work on the website, I've legacy Fortran, C has no portable directory operations so database hits are better in Perl, C++ is virtually gibberish and there is no way I could inflict it on the non-IT background people, and&lt;br /&gt;so on.&lt;br /&gt;&lt;br /&gt;Then I've added to the mix with MinBasic and BASICdraw. So I suppose I am just as responsible. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Rui maciel&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Linny wrote:&lt;br /&gt;&gt; To quote from the article&lt;br /&gt;&lt;br /&gt;&gt; &lt;snip&gt;&lt;br /&gt;&gt; 6. C programming&lt;br /&gt;&gt; As the Web takes over, C languages are also becoming less relevant,&lt;br /&gt;&gt; according to Padveen. "C++ and C Sharp are still alive and kicking,&lt;br /&gt;&gt; but try to find a basic C-only programmer today, and you'll likely&lt;br /&gt;&gt; find a guy that's unemployed and/or training for a new skill," he&lt;br /&gt;&gt; says."&lt;br /&gt;&gt; &lt;snip&gt;&lt;br /&gt;&lt;br /&gt;The author is an idiot. First he tries to claim that C programming is a dying computer skill but then the only thing that he tries to claim is that, by his own account, C-only programmers are "unemployed and/or training for a new skill". Heck, my area is not CS and, besides C, I have&lt;br /&gt;learnt three other programming languages. Although I've been writing C exclusively for about a year at my job, according to the author's metrics I would've been included in the group supporting the claim that C is a dying art.&lt;br /&gt;&lt;br /&gt;Moreover, nowadays every CS graduate is not a C-only programmer. So,according to the author's metrics, all CS graduates could be writing C code for a living and that would still point out that C programming is a dying art.&lt;br /&gt;&lt;br /&gt;And let's not even delve into the "C languages" bit. The author is an idiot from start to end. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Jacob Navia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;lcc-win32 has a sustained download rate of around 500/day.&lt;br /&gt;Since at least 5 years. Not bad for a dead language. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Chris Thomasson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;C is dying? Humm... Try to tell that to the LKML! lol. IMHO, C, C++ and Assembly Language are the kings of the systems languages...&lt;br /&gt;&lt;br /&gt;I hope that low-level systems languages like C never die out! What the heck would we use to prototype new things in? Yikes! &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Serve Laurijssen&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I 100% agree on some of the other skills, but I think nearly every programmer encounters C somewhere in his career. Literature, cross platform libraries, unix/linux tools, hobbyists all use C as main language. Yeah, its not smart to know just C and thats it and if you're only willing to take a job where C is used then you could be unemployed for a while :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt; Johan Bengtsson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;blufox wrote:&lt;br /&gt;&gt; On Jun 17, 12:29 pm, Linny &lt;linvin...@gmail.com&gt; wrote:&lt;br /&gt;&lt;br /&gt;&gt; And yes maybe he went to Redmond to figure out that they program their&lt;br /&gt;&gt; OS in .NET and what not which is not *C*.&lt;br /&gt;&lt;br /&gt;I actually think there is a lot in windows that is written in C, most of what is executing in the kernel probably. Ok I have not actually checked but I guess... The .NET platform is surely *not* written in .NET either... &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Jack klein&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I normally do not bother getting involved in this sot of pointless debate, but I have seen the equivalent of this statement several places lately, so what the heck...&lt;br /&gt;&lt;br /&gt;Certain people, and certain publications (paper or electronic) have certain audiences.  There are a lot of such publications these days aimed at the "IT" audience, and the "Web 2.0" audience.&lt;br /&gt;&lt;br /&gt;It might actually be true for these groups that "C is a dead language".  At least at the levels they work at, generating AJAX to provide many new security vulnerabilities.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;On the other hand, both the clients and servers run on computers whose operating systems are written almost entirely in C.  They execute Java and interpret Javascript in virtual machines and interpreters written almost exclusively in C.  The entire internet architecture runs on&lt;br /&gt;switched and routers programmed almost exclusively in C.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Our good friends at ARM claim over 2,000,000,000 ARM cores shipped in 2006, in off-the-shelf microprocessors/microcontrollers and custom ASICs.  Virtually every one of them is programmed in C.&lt;br /&gt;&lt;br /&gt;So indeed some the authors and readers of some publications may have a world view that doesn't need C anymore.  They are way up there in a cloud of trendy and ever-changing tools.  The tools they use today (ruby on rails is hot right now), will all be extinct and replaced with some other hot new trends in a few years.&lt;br /&gt;&lt;br /&gt;And from there point of view, they might be right.  C programming is definitely a dying profession in the "IT" world.&lt;br /&gt;&lt;br /&gt;But in the rest of the computer world, C has been, is, and probably will be for quite some time to come, the main language of computing.&lt;br /&gt;&lt;br /&gt;There are C implementations, although not all even close to conforming, for everything from the smallest 8-bit microcontrollers to the most advanced 64-bit processors.  C applications range from the tiniest embedded system with a few K octets of code space and RAM to the largest operating systems in existence.&lt;br /&gt;&lt;br /&gt;The "IT" world gets most of the publicity today, because that's where all the venture capital and publicity are, but that it actually a very small segment of all the computing that's done.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;From another, and equally valid, point of view, C programming is essentially all there is, and everything else is down in the noise margin. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Charlton Wilbur&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;"C, while not very visible to the Web 2.0 market, is still thriving in the embedded space and the operating system development space," while true, does not produce the same kind of ad-viewing traffic. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Chris Hills&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Actually they are quite wrong.&lt;br /&gt;&lt;br /&gt;Yes, C is dying for PC programming.   C++, C# C++/CLI  and Java have taken over.&lt;br /&gt;&lt;br /&gt;However C++ itself has been superseded by C#,  C++/CLI and Java.&lt;br /&gt;&lt;br /&gt;C on the other hand is alive and well in a much larger area of programming than desktop. Ie the embedded, real-time and control industries.&lt;br /&gt;&lt;br /&gt;*ANYTHING* that has an led, a battery or indeed power "near" it probably has an MCU it in (cars typically have 100 and 3 networks) these systems are by and large programed in C ( some Ada and three people who use Forth)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;C is very far from dead outside the PC world but C++ is probably on the way out due to MS moving to it's own languages of C# .Net and C++/CLI which is NOT C++. &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;stdazi&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt; &lt;snip&gt;&lt;br /&gt;&gt; 6. C programming&lt;br /&gt;&gt; As the Web takes over.......&lt;br /&gt;&gt; &lt;snip&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;As the web takes over.. With all the applications (apache, mysql, PHP,python) written in C...&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CBFalconer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt; Actually they are quite wrong.&lt;br /&gt;&lt;br /&gt;&gt; Yes, C is dying for PC programming.   C++, C# C++/CLI  and Java&lt;br /&gt;&gt; have taken over.&lt;br /&gt;&lt;br /&gt;&gt; However C++ itself has been superseded by C#,  C++/CLI and Java.&lt;br /&gt;&lt;br /&gt;Nonsense.  You are limiting yourself to the Windoze platform. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Chris Hills&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A Lot of the C++ programmers seem to have moved on to the other languages.  You are correct that C# and C++/CLI are Windows. However off the desktop C is still the major language.&lt;br /&gt;&lt;br /&gt;This is why I think C++ will disappear long before C does. Anywhere there is C++ there are alternatives. However in most of the places where c is used there is no practical alternative.&lt;br /&gt;&lt;br /&gt;That said they are using C++ on the JSF&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6517523294658411645?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6517523294658411645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6517523294658411645' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6517523294658411645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6517523294658411645'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/10/c-dying-skill.html' title='&quot;C A Dying Skill&quot;'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7291410572206624274</id><published>2008-10-13T22:24:00.000-07:00</published><updated>2008-10-13T22:26:40.469-07:00</updated><title type='text'>Primary &amp; Extended Partitions</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SPQtV421TwI/AAAAAAAAAlU/vpq1119-iHE/s1600-h/snapshot12.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SPQtV421TwI/AAAAAAAAAlU/vpq1119-iHE/s320/snapshot12.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5256876519111085826" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7291410572206624274?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7291410572206624274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7291410572206624274' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7291410572206624274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7291410572206624274'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/10/blog-post.html' title='Primary &amp; Extended Partitions'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SPQtV421TwI/AAAAAAAAAlU/vpq1119-iHE/s72-c/snapshot12.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-745180374271294594</id><published>2008-08-31T12:38:00.000-07:00</published><updated>2008-09-17T23:06:05.831-07:00</updated><title type='text'>Deadlock concept</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SNHvwimJDBI/AAAAAAAAAj8/KK7D3xwiOs4/s1600-h/deadlock.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SNHvwimJDBI/AAAAAAAAAj8/KK7D3xwiOs4/s320/deadlock.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5247238658062879762" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SNHvoYsSJxI/AAAAAAAAAj0/1blR6YcfHcI/s1600-h/05122007034.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SNHvoYsSJxI/AAAAAAAAAj0/1blR6YcfHcI/s320/05122007034.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5247238517965334290" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SLrzW15nqYI/AAAAAAAAAjo/Xwp3c3VjJAw/s1600-h/download7.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SLrzW15nqYI/AAAAAAAAAjo/Xwp3c3VjJAw/s320/download7.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5240768690150418818" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-745180374271294594?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/745180374271294594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=745180374271294594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/745180374271294594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/745180374271294594'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/08/deadlock-concept.html' title='Deadlock concept'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SNHvwimJDBI/AAAAAAAAAj8/KK7D3xwiOs4/s72-c/deadlock.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6874439422069320473</id><published>2008-08-04T02:09:00.000-07:00</published><updated>2008-08-04T02:17:38.728-07:00</updated><title type='text'>S-R latch</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;the following is the implementation of S-R latch which i saw  in a book,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SJbH7M86OvI/AAAAAAAAAgs/JAvLzUar0Ws/s1600-h/Scan+3.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SJbH7M86OvI/AAAAAAAAAgs/JAvLzUar0Ws/s320/Scan+3.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5230587837140318962" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;and the following is the truth table based on it&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SJbIYGyRTfI/AAAAAAAAAg0/Dt3tsArg_kE/s1600-h/scan+2.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SJbIYGyRTfI/AAAAAAAAAg0/Dt3tsArg_kE/s320/scan+2.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5230588333701287410" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;now in  the book it is written that when both s &amp; R are made high simultaneously both the o/p will be low and the value of Q is unpredictable (1 or 0)  depending on the circuit condition&lt;br /&gt;now my question is what is this circuit condition that Q depends on ? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;bartc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If both outputs are low then Q will also be low, since Q /is/ the value of one of the outputs. Why is that unpredictable?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;jean marc bourget&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When both S and R are high, Q becomes low as well as Qbar.  What is unpredictable is the state of Q when the signals becomes unasserted.  &lt;span style="font-weight:bold;"&gt;It will depend on the precise order in which they are unasserted&lt;/span&gt;, the gate delays, the input capacitance, the load on Q and Qbar and probably some other things. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt; john fields&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Assuming that S and R are both high and then go low simultaneously,the gate with the shortest input-to-output delay will force the output of the other gate low. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;john popelish&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is not important that they go high simultaneously, only that they *be* high at the same time, since a NOR gate must output a low if either if its inputs is high.So both the S and R force their gates to a low when these signals are high, over riding the cross connections.&lt;br /&gt;&lt;br /&gt;&gt;  and the value of Q is unpredictable (1 or 0)  depending on the&lt;br /&gt;&gt; circuit condition&lt;br /&gt;&lt;br /&gt;&gt;  now my question is what is this circuit condition that Q depends on ?&lt;br /&gt;&lt;br /&gt;It is called a race condition, when both S and R go low at the same time.  At that moment, both gates have two low inputs, one from the just transitioned S or R going low, and one from the most recent forced low output from the other gate.  That means both gated head toward a high output and&lt;br /&gt;the one that gets there first will force the output of the other back to a low.  The circuit conditions involve anything that affects the speed (propagation delay) of each gate, like temperature, transistor gain differences,resistor tolerances, wire lengths, etc.&lt;br /&gt;&lt;br /&gt;The more closely matched the two gates are, the longer it takes for the race condition to be resolved into a winner and a loser.&lt;br /&gt;&lt;br /&gt;Circuit simulations of such a thing, where both gates and their signals can be mathematically identical to many decimal places, can oscillate for many cycles before the race is decided.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6874439422069320473?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6874439422069320473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6874439422069320473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6874439422069320473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6874439422069320473'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/08/s-r-latch.html' title='S-R latch'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SJbH7M86OvI/AAAAAAAAAgs/JAvLzUar0Ws/s72-c/Scan+3.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1181794062994525402</id><published>2008-08-04T01:49:00.000-07:00</published><updated>2009-06-25T10:57:35.699-07:00</updated><title type='text'>RSA</title><content type='html'>Ron Rivest, Adi Shamir, and Leonard Adleman (RSA) were the individuals responsible for creating the RSA standard at MIT, which defines the mathematical properties for using the public-key encryption methodology. The algorithm randomly generates a very large prime number that is used for the public key, which is then consequently used to derive another prime number for the private key via mathematical computations (prime numbers have no pattern). Many forms of RSA encryption are in use today, including the popular PGP.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1181794062994525402?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1181794062994525402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1181794062994525402' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1181794062994525402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1181794062994525402'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/08/loop-back-address.html' title='RSA'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-692376254630883957</id><published>2008-06-30T10:40:00.000-07:00</published><updated>2008-06-30T10:50:50.393-07:00</updated><title type='text'>simple file compression</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;the following is the file compression program ,using elimination of spaces, which I saw in a book&lt;br /&gt;&lt;br /&gt;#include&lt;stdio.h&gt;&lt;br /&gt;#include&lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;int main(int argc,char * argv[])&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   FILE* fs,*ft;&lt;br /&gt;&lt;br /&gt;   fs = fopen(argv[1],"r");&lt;br /&gt;   if(fs == NULL)&lt;br /&gt;   {&lt;br /&gt;     printf("\n Cannot open the file %s",argv[1]);&lt;br /&gt;     exit(1);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   ft = fopen(argv[2],"w");&lt;br /&gt;   if(fs == NULL)&lt;br /&gt;   {&lt;br /&gt;     printf("\n Cannot open the file %s",argv[2]);&lt;br /&gt;     exit(1);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;while( (ch=fgetc(fs)) != EOF)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  if(ch == 32)&lt;br /&gt;  {&lt;br /&gt;      if( (ch=fgetc(fs)) != EOF)&lt;br /&gt;      fputc(ch+127,ft);&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;      fputc(ch,ft);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; fclose(fs);&lt;br /&gt; fclose(ft);&lt;br /&gt;&lt;br /&gt; return EXIT_SUCCESS;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now my questions are as as follows&lt;br /&gt;&lt;br /&gt;1) Is there any other simpler method to compress text files, similar&lt;br /&gt;to the above program(Other than standard algorithms like huffman,LZW)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;mstorkamp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; sophia  wrote:&lt;br /&gt;&lt;br /&gt;&gt;   if(ch == 32)&lt;br /&gt;&gt;   {&lt;br /&gt;&gt;       if( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&gt;       fputc(ch+127,ft);&lt;br /&gt;&gt;   }&lt;br /&gt;&gt;   else&lt;br /&gt;&gt;       fputc(ch,ft);&lt;br /&gt;&lt;br /&gt;What happens when the character represented by the value 32 is the&lt;br /&gt;last character in the file? You are not writing any representation of&lt;br /&gt;that character to your output file. You will not be able to recreate&lt;br /&gt;your source file.&lt;br /&gt;&lt;br /&gt;&gt; Now my questions are as as follows&lt;br /&gt;&lt;br /&gt;&gt; 1) Is there any other simpler method to compress text files, similar&lt;br /&gt;&gt; to the above program(Other than standard algorithms like huffman,LZW)&lt;br /&gt;&lt;br /&gt;yes. Not really a C issue however. First define what you mean by 'text file', then devise a way of mapping the (smaller) domain of your text file into the (larger) domain of an unsigned char. And don't forget to open your destination file for binary access.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;walter roberson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sophia wrote:&lt;br /&gt;&gt;the following is the file compression program ,using elimination of&lt;br /&gt;&gt;spaces, which I saw in a book&lt;br /&gt;&lt;br /&gt;&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&gt;#include&lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;&gt;int main(int argc,char * argv[])&lt;br /&gt;&gt;{&lt;br /&gt;&lt;br /&gt;&gt;   FILE* fs,*ft;&lt;br /&gt;&lt;br /&gt;&gt;   fs = fopen(argv[1],"r");&lt;br /&gt;&gt;   if(fs == NULL)&lt;br /&gt;&gt;   {&lt;br /&gt;&gt;     printf("\n Cannot open the file %s",argv[1]);&lt;br /&gt;&lt;br /&gt;You are not outputing a \n as the last character. It is implementation defined at to whether the last output line will appear in such a case (and it is also possible that it will appear&lt;br /&gt;but then be immediately overwritten by the next shell prompt, making it seem that it did not appear.)&lt;br /&gt;&lt;br /&gt;Error messages are better output to stderr.&lt;br /&gt;&lt;br /&gt;&gt;     exit(1);&lt;br /&gt;&lt;br /&gt;exit(1) does not have a defined effect. The arguments with defined meaning are 0, EXIT_SUCCESS and EXIT_FAILURE&lt;br /&gt;&lt;br /&gt;&gt;   }&lt;br /&gt;&lt;br /&gt;&gt;   ft = fopen(argv[2],"w");&lt;br /&gt;&gt;   if(fs == NULL)&lt;br /&gt;&gt;   {&lt;br /&gt;&gt;     printf("\n Cannot open the file %s",argv[2]);&lt;br /&gt;&gt;     exit(1);&lt;br /&gt;&gt;   }&lt;br /&gt;&lt;br /&gt;&gt;while( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&lt;br /&gt;You have not declared ch by this point. The exact definition of ch is important to the program. For example, if it were declared as 'char' and 'char' happened to be unsigned on that system, then&lt;br /&gt;it would not be possible for ch to compare equal to EOF, which is always negative.&lt;br /&gt;&lt;br /&gt;&gt;{&lt;br /&gt;&lt;br /&gt;&gt;  if(ch == 32)&lt;br /&gt;&lt;br /&gt;What is 32? If you mean a space, code a space, ' ' . The numerical values of particular characters are not specified in C.&lt;br /&gt;&lt;br /&gt;&gt;  {&lt;br /&gt;&gt;      if( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&gt;      fputc(ch+127,ft);&lt;br /&gt;&lt;br /&gt;As the character set representation is not specified by C, it is possible that ch+127 is a valid character in the character set.&lt;br /&gt;&lt;br /&gt;If the file ends in a 32 then that trailing 32 will be lost with your logic.&lt;br /&gt;&lt;br /&gt;I note that you do not open the file in binary mode. It could happen that in the input, there were often space characters immediately proceeding end-of-line indicators. The end of line indicators would be read as '\n' and that '\n' would be transformed by your compressor to '\n'+127 which is unlikely to be an end of line indicator. You could thus end up with output lines that exceeded the maximum text output line size supported by the implementation. You could also potentially happen upon characters for which the character + 127 came out as '\n', thus introducing an end of line where there was none before.&lt;br /&gt;&lt;br /&gt;&gt;  }&lt;br /&gt;&gt;  else&lt;br /&gt;&gt;      fputc(ch,ft);&lt;br /&gt;&lt;br /&gt;&gt;}&lt;br /&gt;&lt;br /&gt;&gt; fclose(fs);&lt;br /&gt;&gt; fclose(ft);&lt;br /&gt;&lt;br /&gt;&gt; return EXIT_SUCCESS;&lt;br /&gt;&gt;}&lt;br /&gt;&gt;Now my questions are as as follows&lt;br /&gt;&lt;br /&gt;&gt;1) Is there any other simpler method to compress text files, similar&lt;br /&gt;&gt;to the above program(Other than standard algorithms like huffman,LZW)&lt;br /&gt;&lt;br /&gt;Yes, many of them, most equally inefficient. The code you give at best compresses space followed by a character to a different character code, and leaves everything else alone -- it doesn't even try to compress runs of spaces into something more efficient. If the code were to be applied to typical English text, it would produce a more efficient output if, instead of compressing spaces, it compressed 'e', 't', 'a', 'i', 'o', or 'n', all of which occur in English text with greater frequency than space does.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;malcom mclean&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;squnch compression. It's a sliding dictionarty method that has seen induistrial use because of its super-fast decompress.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;barry schwarz&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sophia wrote:&lt;br /&gt;&lt;br /&gt;&gt;the following is the file compression program ,using elimination of&lt;br /&gt;&gt;spaces, which I saw in a book&lt;br /&gt;&lt;br /&gt;Was it listed as a bad example?  Perhaps the book was intended as a satire?&lt;br /&gt;&lt;br /&gt;&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&gt;#include&lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;&gt;int main(int argc,char * argv[])&lt;br /&gt;&gt;{&lt;br /&gt;&lt;br /&gt;&gt;   FILE* fs,*ft;&lt;br /&gt;&lt;br /&gt;&gt;   fs = fopen(argv[1],"r");&lt;br /&gt;&lt;br /&gt;How does the program know argv[1] is not NULL or for that matter that&lt;br /&gt;it even exists?&lt;br /&gt;&lt;br /&gt;&gt;   if(fs == NULL)&lt;br /&gt;&gt;   {&lt;br /&gt;&gt;     printf("\n Cannot open the file %s",argv[1]);&lt;br /&gt;&gt;     exit(1);&lt;br /&gt;&gt;   }&lt;br /&gt;&lt;br /&gt;&gt;   ft = fopen(argv[2],"w");&lt;br /&gt;&gt;   if(fs == NULL)&lt;br /&gt;&gt;   {&lt;br /&gt;&gt;     printf("\n Cannot open the file %s",argv[2]);&lt;br /&gt;&gt;     exit(1);&lt;br /&gt;&gt;   }&lt;br /&gt;&lt;br /&gt;&gt;while( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&lt;br /&gt;Where is ch declared?&lt;br /&gt;&lt;br /&gt;&gt;{&lt;br /&gt;&lt;br /&gt;&gt;  if(ch == 32)&lt;br /&gt;&lt;br /&gt;32 is not the value of ' ' on my system.&lt;br /&gt;&lt;br /&gt;&gt;  {&lt;br /&gt;&gt;      if( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&gt;      fputc(ch+127,ft);&lt;br /&gt;&lt;br /&gt;On my system adding 127 to a printable character value will produce a value that won't fit in a char.  While this technically isn't overflow since fputc takes an int, it will mess up the output file.&lt;br /&gt;&lt;br /&gt;It appears to skip only one space.  And it does so without regard to whether the space is "significant". &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Barry Schwarz  wrote:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt; sophia wrote:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt; &gt;the following is the file compression program ,using elimination of&lt;br /&gt;&gt; &gt;spaces, which I saw in a book&lt;br /&gt;&lt;br /&gt;&gt; Was it listed as a bad example?  Perhaps the book was intended as a&lt;br /&gt;&gt; satire?&lt;br /&gt;&lt;br /&gt;i don't know if the book was intended as sattire or not .The book ISBN number is 81-7656-537-7 and this program is given in page no: 55&lt;br /&gt;&lt;br /&gt;&gt; &gt;while( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&lt;br /&gt;&gt; Where is ch declared?&lt;br /&gt;&lt;br /&gt;&gt; &gt;{&lt;br /&gt;&lt;br /&gt;&gt; &gt;  if(ch == 32)&lt;br /&gt;&lt;br /&gt;&gt; 32 is not the value of ' ' on my system.&lt;br /&gt;&lt;br /&gt;&gt; &gt;  {&lt;br /&gt;&gt; &gt;      if( (ch=fgetc(fs)) != EOF)&lt;br /&gt;&gt; &gt;      fputc(ch+127,ft);&lt;br /&gt;&lt;br /&gt;&gt; On my system adding 127 to a printable character value will produce a&lt;br /&gt;&gt; value that won't fit in a char.  While this technically isn't overflow&lt;br /&gt;&gt; since fputc takes an int, it will mess up the output file.&lt;br /&gt;&lt;br /&gt;&gt; It appears to skip only one space.  And it does so without regard to&lt;br /&gt;&gt; whether the space is "significant".&lt;br /&gt;&lt;br /&gt; i think to skip more than one space the following changes can be made(assuming 32 stands for ' ')&lt;br /&gt;&lt;br /&gt;while( (ch=fgetc(fs)) != EOF)&lt;br /&gt;{&lt;br /&gt;  if(ch == 32)&lt;br /&gt;  {&lt;br /&gt;    count = 1;&lt;br /&gt;    while( (ch=fgetc(fs)) == 32)&lt;br /&gt;    count++;&lt;br /&gt;    fputc(count+127,ft);&lt;br /&gt;  }&lt;br /&gt;  fputc(ch,ft);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; fputc takes signed int or unsigned int ? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;santosh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It takes a signed int argument, but converts that to an unsigned char before writing to the stream. If the write fails it returns EOF, otherwise the character it wrote converted to int.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-692376254630883957?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/692376254630883957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=692376254630883957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/692376254630883957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/692376254630883957'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/06/simple-file-compression.html' title='simple file compression'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-5326028941488385599</id><published>2008-06-07T10:59:00.000-07:00</published><updated>2008-06-09T11:11:50.936-07:00</updated><title type='text'>pointer variable Vs reference variables</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sulekha&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;can anyone explain the differences between pointer variable and reference variables ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;thomas o eilidhe&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;References don't exist in C, they're a C++ thing. A reference is simply a pointer with the following features:&lt;br /&gt;&lt;br /&gt; * You don't have to dereference it, it gets dereferenced automagically&lt;br /&gt; * You can't change what it points to&lt;br /&gt;&lt;br /&gt;So the following two are equivalent:&lt;br /&gt;&lt;br /&gt;    void Func(int* constp) { *p = 5; }&lt;br /&gt;&lt;br /&gt;    void Func(int &amp;i) { i = 5; }&lt;br /&gt;&lt;br /&gt;If you want references in C, then you can play around with macroes:&lt;br /&gt;&lt;br /&gt;    void Func(int* const p)&lt;br /&gt;    {&lt;br /&gt;      #define i (*p)&lt;br /&gt;&lt;br /&gt;        i = 5;&lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;malcom mclean&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;References exist in Java and C++, and are basically syntactic sugar for pointers. They point only to one object, and may never be null. However the variable is passed as an address, ie a pointer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Malcolm McLean wrote:&lt;br /&gt;&lt;br /&gt;&gt; sulekhasweety wrote &lt;br /&gt;&lt;br /&gt;&gt;&gt; can anyone explain the differences between pointer variable and&lt;br /&gt;&gt;&gt; reference variables ?&lt;br /&gt;&lt;br /&gt;&gt; References exist in Java and C++, and are basically syntactic sugar for&lt;br /&gt;&gt; pointers. They point only to one object, and may never be null. However&lt;br /&gt;&gt; the variable is passed as an address, ie a pointer.&lt;br /&gt;&lt;br /&gt;&lt;off-topic&gt;&lt;br /&gt;&lt;br /&gt;Dunno about C++, but what you say about Java is wrong on all three points (or at least on two and a half points, allowing some wiggle room in interpreting "they" in the second point):&lt;br /&gt;&lt;br /&gt;     1) A Java "reference" *is* what C calls a "pointer," not a&lt;br /&gt;        pointer hiding behind a sugar-coated facade.  (Java gives&lt;br /&gt;        the programmer little freedom to manipulate its pointers,&lt;br /&gt;        but they're indisputably pointers.  Note what's thrown for&lt;br /&gt;        misuse of a null reference: NullPointerException.)&lt;br /&gt;&lt;br /&gt;     2) A Java reference value refers to only one object, just as&lt;br /&gt;        a C pointer value refers to only one object.  A Java&lt;br /&gt;        reference variable, just like a C pointer variable, can&lt;br /&gt;        refer to different objects at different times.&lt;br /&gt;&lt;br /&gt;     3) A Java reference value or variable can be null.&lt;br /&gt;&lt;br /&gt;&lt;/off-topic&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-5326028941488385599?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/5326028941488385599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=5326028941488385599' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5326028941488385599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5326028941488385599'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/06/pointer-variable-vs-reference-variables.html' title='pointer variable Vs reference variables'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7801062260767152621</id><published>2008-05-21T10:56:00.000-07:00</published><updated>2008-05-21T11:10:43.908-07:00</updated><title type='text'>middle of a linked list - interview question</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Question goes like this.. while traversing the Node.. Once it is a middle of the Single Linked List it should notify.. This should happen with out further traversal to the next node.&lt;br /&gt;&lt;br /&gt;the solution i got from my friends is as follows:-&lt;br /&gt;&lt;br /&gt;may be we can do it using two pointers ( although i m not quite sure whether two pointers r allowed in the question or not)one pointer will be incremented by 1 , while other one will be incremented by 2 , when second one reaches the last node, first one will be in the middle.(though nodes after the middle element are traversed by the second pointer in this solution)&lt;br /&gt;&lt;br /&gt;can any one give me a correct solution to this problem..... ???&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;pete&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Not better than what you already thought of. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CBfalconer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You've already got it there.  Just put it in a function:&lt;br /&gt;&lt;br /&gt;   node *midpt(node *root) {&lt;br /&gt;      node *p = root;&lt;br /&gt;&lt;br /&gt;      while (p) {&lt;br /&gt;         p = p -&gt; next;&lt;br /&gt;         if (p) p= p-&gt;next;&lt;br /&gt;         root= root -&gt; next;&lt;br /&gt;      }&lt;br /&gt;      return root;&lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;juha nieminen&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This question is too vague. What kind of list is it? Is it a singly-linked list or a doubly-linked list? Do you know the amount of elements in the list? Are you supposed to do this on an existing list implementation, or are you allowed to modify the list implementation to allow doing things like this? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;james harris&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Pointers to linked list nodes are not helpful as the nodes are not necessarily adjacent in memory. And to get the second pointer to the end of the list requires traversing the middle node which is&lt;br /&gt;prohibited in the question.&lt;br /&gt;&lt;br /&gt;You need one extra piece of information which is missing from the question. For example, if you know the number of nodes - i.e. the length of the linked list, you can stop when you reach the middle.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;pete&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It's a classic technique for splitting linked lists.&lt;br /&gt;&lt;br /&gt;http://www.mindspring.com/~pfilandr/C/lists_and_files/list_lib.h&lt;br /&gt;http://www.mindspring.com/~pfilandr/C/lists_and_files/list_lib.c&lt;br /&gt;&lt;br /&gt;static list_type *split_list(list_type *head)&lt;br /&gt;{&lt;br /&gt;     list_type *tail;&lt;br /&gt;&lt;br /&gt;     tail = head -&gt; next;&lt;br /&gt;     while ((tail = tail -&gt; next) != NULL&lt;br /&gt;         &amp;&amp; (tail = tail -&gt; next) != NULL)&lt;br /&gt;     {&lt;br /&gt;         head = head -&gt; next;&lt;br /&gt;     }&lt;br /&gt;     tail = head -&gt; next;&lt;br /&gt;     head -&gt; next = NULL;&lt;br /&gt;     return tail;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Also for detecting circular linked lists. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;james harris&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Doesn't this include traversal past the middle node (as part of the tail advancing) which is prohibited in the question? It should be said that the question is missing at least some information so maybe your solution is what they were looking for as the head pointer doesn't&lt;br /&gt;pass the middle. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;pete &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;maybe&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7801062260767152621?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7801062260767152621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7801062260767152621' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7801062260767152621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7801062260767152621'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/middle-of-linked-list-interview.html' title='middle of a linked list - interview question'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1695584468607815100</id><published>2008-05-21T10:10:00.000-07:00</published><updated>2008-05-23T09:01:15.543-07:00</updated><title type='text'>tree reconstruction</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Is it possible to re create a binary tree from given preorder and post order traversals ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt; Ben pfaff&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I believe that there is an exercise in Knuth vol. 1 on this topic or one closely related.  I imagine that it has an answer, too.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;antonius twink&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Well...&lt;br /&gt;&lt;br /&gt;There's an ambiguity as soon as you have a node with no left descendant or no right descendant. For example,&lt;br /&gt;&lt;br /&gt;    a             &lt;br /&gt;  /                    &lt;br /&gt; b                      &lt;br /&gt;&lt;br /&gt;and &lt;br /&gt;&lt;br /&gt; a&lt;br /&gt;  \&lt;br /&gt;   b&lt;br /&gt;&lt;br /&gt;both have preorder ab and postorder ba.&lt;br /&gt;&lt;br /&gt;Of course, these trees are really the same, for some interpretation of "really the same". &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;walter roberson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes. Look for,&lt;br /&gt;"An optimal parallel algorithm to reconstruct a binary tree from its traversals" &lt;br /&gt;by Stephan Olariu, Michael Overstreet and Zhaofang Wen&lt;br /&gt;&lt;br /&gt;You might find a linear version more useful,&lt;br /&gt;&lt;br /&gt;http://citeseer.ist.psu.edu/andersson90construction.html&lt;br /&gt;&lt;br /&gt;Construction of a Tree from its Traversals in Optimal Time and Space (1990)&lt;br /&gt;Arne Andersson, Svante Carlsson&lt;br /&gt;&lt;br /&gt;http://citeseer.ist.psu.edu/166720.html&lt;br /&gt;&lt;br /&gt;Constructing a Binary Tree Efficiently from Its Traversals (1998) Erkki Makinen&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1695584468607815100?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1695584468607815100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1695584468607815100' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1695584468607815100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1695584468607815100'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/law-of-freely-falling-bodies.html' title='tree reconstruction'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-9141597493807062512</id><published>2008-05-21T10:05:00.000-07:00</published><updated>2008-06-01T22:08:47.964-07:00</updated><title type='text'>Loop Unrolling</title><content type='html'>It is a compilation technique for Instruction-Level Parallelism.Individual loop iterations tend to have relatively low instruction-level parallelism because they often contain chains of dependent instructions, and because of the limited no: of instructions between the branches.&lt;br /&gt;&lt;br /&gt;loop unrolling addresses this limitation by transforming a loop with N iterations into a loop with N/M iterations, where each iteration in the new loop does the work of M iterations of the old loop.This increases the no: of instructions between the branches, giving the compiler and the hardware  more oppurtunity to find instruction level parallelism&lt;br /&gt;&lt;br /&gt;Ex 1:-   &lt;span style="font-weight:bold;"&gt;Orginal loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       for(i=0;i&lt;100;i++)&lt;br /&gt;       {&lt;br /&gt;         a[i] = b[i] + c[i];&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight:bold;"&gt;Unrolled loop&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;   for(i=0;i&lt;100;i += 2)&lt;br /&gt;   {&lt;br /&gt;      a[i]   =  b[i]   + c[i];&lt;br /&gt;      a[i+1] =  b[i+1] + c[i+1];&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ex 2:-&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;Orginal loop&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;        for(i=0;i&lt;100;i++)&lt;br /&gt;        {&lt;br /&gt;          a[i] = b[i] + c[i];&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-weight:bold;"&gt;Unrolled loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        for(i=0;i&lt;100;i+=8)&lt;br /&gt;        {&lt;br /&gt;          a[i] = b[i] + c[i];&lt;br /&gt;          a[i+1] = b[i+1] + c[i+1];&lt;br /&gt;          a[i+2] = b[i+2] + c[i+2];&lt;br /&gt;          a[i+3] = b[i+3] + c[i+3];&lt;br /&gt;          a[i+4] = b[i+4] + c[i+4];&lt;br /&gt;          a[i+5] = b[i+5] + c[i+5];&lt;br /&gt;          a[i+6] = b[i+6] + c[i+6];&lt;br /&gt;          a[i+7] = b[i+7] + c[i+7];&lt;br /&gt;        }   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;A loop is said to have unrolled n times if each iteration of the unrolled loop performs a work of n iterations of the orginal loop&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-9141597493807062512?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/9141597493807062512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=9141597493807062512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9141597493807062512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9141597493807062512'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/perfect-numbers.html' title='Loop Unrolling'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-9113178188817675568</id><published>2008-05-13T23:38:00.000-07:00</published><updated>2008-05-13T23:42:03.765-07:00</updated><title type='text'>Is  node deletion in BST commutative ?</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;is  node deletion in BST commutative?,commutative in the sense,deletion of a node x and then y leave the tree same as that ofdeleting y first and then x? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;moi&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Why would you want to know ?&lt;br /&gt;As long as the resulting trees still represent the right ordering af,they can be _considered_ equal.&lt;br /&gt;&lt;br /&gt;(re-)Balancing is another aspect, which may need to be taken care of.Do you consider the trees before and after balancing the same ?&lt;br /&gt;&lt;br /&gt;Please first give your definition of "same tree" &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;richard harter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If by "the tree the same" you mean having the same shape and linkage then the answer depends upon how you implement the deletion.  What happens when you delete a node that has both left&lt;br /&gt;and right childre is that the tree is split into two trees that must then be relinked. There are many ways that this can be done.That said, one fairly standard way to do this is to replace the&lt;br /&gt;node by its immediate successor.IIANM replacement by the successor (or predecessor) is commutative in your sense. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;moi&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Simplest case (delete node X from a tree):&lt;br /&gt;X has no children: we are done.&lt;br /&gt;X has only one non-null child: put the child in X's place&lt;br /&gt;X has two non empty children: choose one of them to take X's place,&lt;br /&gt;&lt;br /&gt;insert the other (including subtree, which is already ordered, and guaranteed not to overlap) onto the new X'.&lt;br /&gt;&lt;br /&gt;This cheap method will maintain order, but destroys balance.It is up to you to decide if it is "commutative" :-}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-9113178188817675568?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/9113178188817675568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=9113178188817675568' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9113178188817675568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9113178188817675568'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/is-node-deletion-in-bst-commutative.html' title='Is  node deletion in BST commutative ?'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-5131694443443210677</id><published>2008-05-10T11:43:00.000-07:00</published><updated>2008-05-10T11:46:07.551-07:00</updated><title type='text'>Electricity</title><content type='html'>&lt;strong&gt;Electricity&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Mains Electricity - The Three Wires - Do Not Touch.&lt;br /&gt;&lt;br /&gt;The UK mains electricity supply has three wires.They are called Live, Neutral and Earth and each wire has its own colour. Live is Brown, Neutral is Blue, Earth is Green and Yellow stripes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Live wire is connected directly to the generators of the electricity supply company.NEVER touch this wire, it can kill you!!&lt;br /&gt;&lt;br /&gt;The Neutral wire returns the electricity to the generator after it has passed through the appliance, to complete the circuit. NEVER touch this wire!!&lt;br /&gt;In a complete circuit, it carries the same electricity as the Live wire.&lt;br /&gt;&lt;br /&gt;The Earth wire usually carries no electricity,it is there as a safety device.&lt;br /&gt;If something in the appliance goes wrong, or it is wired incorrectly,then the Earth wire carries the same electricity as the Live wire.To be completely safe, NEVER touch this wire either!!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Earthing.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If the outer casing (the outside bit) of an appliance is a conductor (made of metal), then it can be made safe by Earthing&lt;br /&gt;&lt;br /&gt;The Earth wire usually carries no electricity,it is connected to the metal case on the inside of the appliance.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_hNduP9F5jm4/SCXtMpv9O_I/AAAAAAAAACg/NRAzSG7Wreo/s1600-h/Earth-Wire-Connection.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_hNduP9F5jm4/SCXtMpv9O_I/AAAAAAAAACg/NRAzSG7Wreo/s320/Earth-Wire-Connection.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5198822146490317810" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If something goes wrong inside the appliance and the Live wire touches the metal case,then the Earth wire acts like a Neutral wire and completes the circuit for the electricity.A very large current suddenly flows because the metal case has little resistance. This large current blows the fuse in the plug and disconnects the appliance from the power supply.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-5131694443443210677?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/5131694443443210677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=5131694443443210677' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5131694443443210677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5131694443443210677'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/electricity.html' title='Electricity'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_hNduP9F5jm4/SCXtMpv9O_I/AAAAAAAAACg/NRAzSG7Wreo/s72-c/Earth-Wire-Connection.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1736886567879333175</id><published>2008-05-10T11:08:00.000-07:00</published><updated>2008-06-01T01:32:21.612-07:00</updated><title type='text'>C program</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;var pageTracker = _gat._getTracker("UA-4163235-1");&lt;br /&gt;pageTracker._initData();&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;sulekha&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;can any one give a brief outline of the different stages in the execution of a C program , in terms of compilation, pre-processing,linking etc &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;pete&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No.&lt;br /&gt;A C implementation can do two different things.&lt;br /&gt;It can translate a C program.&lt;br /&gt;It can execute a C program.&lt;br /&gt;&lt;br /&gt;Compilation, pre-processing, linking are related to translation.&lt;br /&gt;&lt;br /&gt;N869&lt;br /&gt;&lt;br /&gt;        5.1.1.2  Translation phases&lt;br /&gt;&lt;br /&gt;        [#1] The precedence among the syntax rules of translation is&lt;br /&gt;        specified by the following phases.5)&lt;br /&gt;&lt;br /&gt;          1.  Physical  source  file multibyte characters are mapped&lt;br /&gt;              to the  source  character  set  (introducing  new-line&lt;br /&gt;              characters  for  end-of-line indicators) if necessary.&lt;br /&gt;              Trigraph  sequences  are  replaced  by   corresponding&lt;br /&gt;              single-character internal representations.&lt;br /&gt;&lt;br /&gt;          2.  Each instance of a backslash character (\) immediately&lt;br /&gt;              followed by a new-line character is deleted,  splicing&lt;br /&gt;              physical  source  lines  to form logical source lines.&lt;br /&gt;              If, as a result, a character sequence that matches the&lt;br /&gt;              syntax  of a universal character name is produced, the&lt;br /&gt;              behavior is undefined.  Only the last backslash on any&lt;br /&gt;              physical  source line shall be eligible for being part&lt;br /&gt;              of such a splice.  A source file  that  is  not  empty&lt;br /&gt;              shall  end in a new-line character, which shall not be&lt;br /&gt;              immediately preceded by a backslash  character  before&lt;br /&gt;              any such splicing takes place.&lt;br /&gt;&lt;br /&gt;          3.  The  source  file  is  decomposed  into  preprocessing&lt;br /&gt;              tokens6)   and  sequences  of  white-space  characters&lt;br /&gt;              (including comments).  A source file shall not end  in&lt;br /&gt;              a partial preprocessing token or in a partial comment.&lt;br /&gt;              Each comment is replaced by one space character.  New-&lt;br /&gt;              line  characters  are retained.  Whether each nonempty&lt;br /&gt;              sequence of white-space characters other than new-line&lt;br /&gt;              is  retained  or  replaced  by  one space character is&lt;br /&gt;              implementation-defined.&lt;br /&gt;&lt;br /&gt;          4.  Preprocessing   directives   are    executed,    macro&lt;br /&gt;              invocations  are  expanded, and _Pragma unary operator&lt;br /&gt;              expressions are executed.   If  a  character  sequence&lt;br /&gt;              that  matches the syntax of a universal character name&lt;br /&gt;              is produced by  token  concatenation  (6.10.3.3),  the&lt;br /&gt;              behavior   is  undefined.   A  #include  preprocessing&lt;br /&gt;              directive causes the named header or source file to be&lt;br /&gt;              processed  from  phase 1 through phase 4, recursively.&lt;br /&gt;              All preprocessing directives are then deleted.&lt;br /&gt;&lt;br /&gt;          5.  Each source character set member and  escape  sequence |&lt;br /&gt;              in   character   constants   and  string  literals  is&lt;br /&gt;              converted to the corresponding member of the execution&lt;br /&gt;              character set; if there is no corresponding member, it&lt;br /&gt;              is converted to an implementation-defined member.&lt;br /&gt;&lt;br /&gt;          6.  Adjacent string literal tokens are concatenated.&lt;br /&gt;&lt;br /&gt;          7.  White-space characters separating tokens are no longer&lt;br /&gt;              significant.   Each  preprocessing  token is converted&lt;br /&gt;              into a token.  The resulting tokens are  syntactically&lt;br /&gt;              and   semantically   analyzed   and  translated  as  a&lt;br /&gt;              translation unit.&lt;br /&gt;&lt;br /&gt;          8.  All  external  object  and  function  references   are&lt;br /&gt;              resolved.   Library  components  are linked to satisfy&lt;br /&gt;              external  references  to  functions  and  objects  not&lt;br /&gt;              defined   in   the   current  translation.   All  such&lt;br /&gt;              translator output is collected into  a  program  image&lt;br /&gt;              which contains information needed for execution in its&lt;br /&gt;              execution environment.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;richard heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are eight translation phases. They are documented in the C Standard.Briefly, they are:&lt;br /&gt;&lt;br /&gt;1) physical source file characters are mapped to the source character set,&lt;br /&gt;and trigraph replacements happen;&lt;br /&gt;2) line splicing happens;&lt;br /&gt;3) source file is decomposed into pp-tokens; comments are removed (replaced&lt;br /&gt;by one space character);&lt;br /&gt;4) preprocessing directives are executed and macro invocations are&lt;br /&gt;expanded;&lt;br /&gt;5) escape sequences are converted into characters;&lt;br /&gt;6) string literal concatenation occurs;&lt;br /&gt;7) pp-tokens are converted to tokens, and translation (compilation, if you&lt;br /&gt;like) occurs;&lt;br /&gt;8) linking.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;smarty&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.the file u create in editor is saved as ".c"  file&lt;br /&gt;2. this '.s' file is then PREPROCESSED for compilation .&lt;br /&gt;3. the preprocessed file undergoes compilation to generate a&lt;br /&gt;'.asm' (assembly file) or '.s' or '.src' file.&lt;br /&gt;4. this source file is assembled to generate a '.obj' file&lt;br /&gt;5. this .obj file is combined with other '.obj' or '.lib' files to&lt;br /&gt;generate an executable file. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;chris H&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;smarty wrote&lt;br /&gt;&gt;1.the file u create in editor is saved as ".c"  file&lt;br /&gt;&gt;2. this '.s' file is then PREPROCESSED for compilation .&lt;br /&gt;&gt;3. the preprocessed file undergoes compilation to generate a&lt;br /&gt;&gt;'.asm' (assembly file) or '.s' or '.src' file.&lt;br /&gt;&gt;4. this source file is assembled to generate a '.obj' file&lt;br /&gt;&gt;5. this .obj file is combined with other '.obj' or '.lib' files to&lt;br /&gt;&gt;generate an executable file. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1 You write text (C source) in to a TEXT  editor. Often the editor in an IDE&lt;br /&gt;&lt;br /&gt;2 You "Compile" the source.&lt;br /&gt;&lt;br /&gt;These days this will give you an object file for linking.Under the hood there are several steps&lt;br /&gt;&lt;br /&gt;2.1 The pre-processor does a *textual* replacement of macros and defines. This is why it is often required that macros have  ( ) around them when they are defined.&lt;br /&gt;&lt;br /&gt;2.2 the now expanded text file is compiled.  At one time this could be up to THREE passes and the command "CC file.c" actually fed file.c to a batch file called cc that called the three parts of the compiler.This would turn our assembler code in a text file. You then needed to&lt;br /&gt;assemble the text file to object code.&lt;br /&gt;&lt;br /&gt;Modern compilers are "single pass"  which means they hide all the messing about and go from the  source code text to object files in "one pass" and do not generate assembler code. Thus a separate assembler is not needed.  In reality there is usually a pre-proccessor phase and the compiler will generate intermediate files and tables.&lt;br /&gt;&lt;br /&gt;These days there is more memory. In the Good old Days you use to have to swap floppy disks for compile, assemble and link phases :-)  (and 8inch floppies at that :-))))&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;3 linking.&lt;/span&gt; This links the various program object files and the library&lt;br /&gt;files&lt;br /&gt;&lt;br /&gt;linking needs to sort out all the extern function and data calls between modules and the library. It knits the modules together in one object file&lt;br /&gt;&lt;br /&gt;In some cases years ago where there is only a single file and no calls to the library the object file from the assembler or compiler could run without linking.&lt;br /&gt;&lt;br /&gt;The out put from the linker can be further processed to give S-Rec,Intel Hex or other files for downloading to eprom/flash programmers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1736886567879333175?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1736886567879333175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1736886567879333175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1736886567879333175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1736886567879333175'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/harshad-number.html' title='C program'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2472726183519932755</id><published>2008-05-10T09:31:00.000-07:00</published><updated>2008-05-10T09:33:16.680-07:00</updated><title type='text'>The cutting sticks problem</title><content type='html'>&lt;strong&gt;aarklon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The cutting sticks problem---given a stick of length L and a set of points where it has to be cut. If the cost of making a cut is equal to the length of the stick, what is the best algorithm to find the optimal sequence of cuts(giving minimum cost) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;nathaniel calloway&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This is not the cutting sticks problem I've heard of before. &lt;br /&gt;&lt;br /&gt;Your problem has an intuitive answer: minimize the geometric mean of stick lengths as they are cut. Now you can either just write some code based on that, or you can write some inefficient but sexy tail recursive algorithm that converges on the intuitive answer. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Or you can change the problem to make it sufficiently complex that there are different schemes based on the initial conditions. That's how a CS professor would approach the subject. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;greg herlihy&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt; would advise always cutting the stick at whichever point is closest to the middle. After all, if we were able to divide the sticks exactly in half with each cut - we would always have the shortest possible set of sticks for the number of cuts we had made. &lt;br /&gt;&lt;br /&gt;And - in order to reduce the cost of each cut - we must reduce the length of our sticks as rapidly as we can with our cuts. Therefore, it makes sense for us to cut each stick at the point closest to its middle - in order for our cuts to come closest to the ideal stick- shortening cutting protocol. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;willem&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Greg wrote: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;) I would advise always cutting the stick at whichever point is closest &lt;br /&gt;) to the middle. After all, if we were able to divide the sticks exactly &lt;br /&gt;) in half with each cut - we would always have the shortest possible set &lt;br /&gt;) of sticks for the number of cuts we had made. &lt;br /&gt;) &lt;br /&gt;) And - in order to reduce the cost of each cut - we must reduce the &lt;br /&gt;) length of our sticks as rapidly as we can with our cuts. Therefore, it &lt;br /&gt;) makes sense for us to cut each stick at the point closest to its &lt;br /&gt;) middle - in order for our cuts to come closest to the ideal stick- &lt;br /&gt;) shortening cutting protocol. &lt;br /&gt;&lt;br /&gt;Counterexample: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Assuming a stick of unit length. &lt;br /&gt;Suppose the three cuts have to be placed at 0.45, 0.50 and 0.55. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As per your algorithm, the first cut is at the center (0.50).If we cut first at 0.50 and then at 0.45 and 0.55, the total cost would be 1 + 0.50 + 0.50 = 2 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, if we first cut 0.45, then 0.55 and finally 0.50, the total cost would be 1 + 0.55 + 0.10 = 1.65 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;greg herlihy&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Then there probably is no practical algorithm to find the optimal solution (or at least none has ever been discovered). Instead, a program would have to try every possible combination of cuts to find out which is the cheapest (of course such an exhaustive search would quickly become prohibitively slow as the number of cuts grew). &lt;br /&gt;&lt;br /&gt;Essentially, this problem appears to be the "knapsack" problem (given a knapsack containing sticks of different lengths - find the combination of sticks that add up to a particular length) in disguise.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2472726183519932755?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2472726183519932755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2472726183519932755' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2472726183519932755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2472726183519932755'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/cutting-sticks-problem.html' title='The cutting sticks problem'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8559348770931286258</id><published>2008-05-09T11:38:00.000-07:00</published><updated>2008-05-09T11:41:43.572-07:00</updated><title type='text'>B-tree</title><content type='html'>&lt;strong&gt;allan teo&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Can someone tell me what does b-trees stand for? &lt;br /&gt;Balanced trees? Or is it just simply b-trees (without any meaning)? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ken pizzini&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;*NO!*  B-trees are not at all binary trees!  B-trees are balanced multiway trees designed for external (read:  disk) storage of data with efficient data access operations.  Binary trees are two-way trees designed for effecient internal (read: RAM) access.  Beyond the fact that they both start with a B and are both instances of tree structures they are completely different. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;lawrence kirby&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If it has any meaning I believe it would be "balanced". However it really just refers to a specific datastructure&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;kai zimmerman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;B-tree's are not binary trees and most times not balanced.  They are efficient for indexing large amounts of data on slower storage medias. They try to reduce the access time to these medias. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;chris bitmead&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;B=Balanced. The reason is that the algorithm forces the tree to have uniform depth at all times. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Gareth McCaughan&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Also, saying "it's a balanced tree" may mislead some people;note that it's not a balanced *binary* tree, but a balanced tree with rather more branching than that. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Andrew hamilton wright&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In the excellent article I have "The Ubiquitous B-Tree" (Douglas Comer, Purdue University) from the ACM "Computing Surveys", vol 11, No. 2, 1979, when referring to the original Bayer/MacCreight article he states: &lt;br /&gt;&lt;br /&gt;The origin of "B-tree" has never been explained by the authors.  As we shall see, "balanced", "broad" or "bushy" might apply.  Others suggest that the "B" stands for Boeing (where Bayer worked, parenthesis mine).Because of his contributions, however, it seems appropriate to think of B-trees as "Bayer"-trees.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Hans amund rosbach&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Knuth writes about the B-tree in his "The art of computer programming" in chapter 6.2.4 Multiway trees. He gives the original source [Acta Informatica (1972), 173-189], but does not give any explanation for the name. &lt;br /&gt;&lt;br /&gt;I'll give his description of it though: &lt;br /&gt;&lt;br /&gt;A B-tree of order m is a tree which satisfies the following properties: &lt;br /&gt;&lt;br /&gt;1. Every node has &lt;= m sons. &lt;br /&gt;2. Every node, except for the root and the leaves, has &gt;= m/2 sons. &lt;br /&gt;3. The root has at least 2 sons (unless it is a leaf). &lt;br /&gt;4. All leaves appear on the same level. &lt;br /&gt;5. A nonleaf node with k sons contains k-1 keys.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8559348770931286258?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8559348770931286258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8559348770931286258' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8559348770931286258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8559348770931286258'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/b-tree.html' title='B-tree'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2463013139449488858</id><published>2008-05-07T13:25:00.000-07:00</published><updated>2008-05-07T13:30:52.666-07:00</updated><title type='text'>no: of nodes in each level of binary tree</title><content type='html'>&lt;strong&gt;sophia&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;How good is this function which is used to find  the no: of nodes &lt;br /&gt;in each level of the binary tree. ? &lt;br /&gt;&lt;br /&gt;int arrlev[100]; &lt;br /&gt;&lt;br /&gt;void preorder(struct btree *n,int lev) &lt;br /&gt;{ &lt;br /&gt;  if(!(n)) &lt;br /&gt;  return; &lt;br /&gt;&lt;br /&gt;  arrlev[lev]++; &lt;br /&gt;  lev++; &lt;br /&gt;&lt;br /&gt;  preorder(n-&gt;left,lev); &lt;br /&gt;  preorder(n-&gt;right,lev); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;walter roberson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;sophia  wrote: &lt;br /&gt;&gt;How good is this function which is used to find  the no: of nodes &lt;br /&gt;&gt;in each level of the binary tree. ? &lt;br /&gt;&gt;int arrlev[100]; &lt;br /&gt;&gt;void preorder(struct btree *n,int lev) &lt;br /&gt;&gt;{ &lt;br /&gt;&gt;       if(!(n)) &lt;br /&gt;&gt;       return; &lt;br /&gt;&lt;br /&gt;&gt;       arrlev[lev]++; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When you restrict the number of levels in the counters (which you do in your declaration of arrlev), then before you write into arrlev[lev] you need to check that you are not overflowing the end of the array. &lt;br /&gt;&lt;br /&gt;&gt;       lev++; &lt;br /&gt;&gt;      preorder(n-&gt;left,lev); &lt;br /&gt;&gt;      preorder(n-&gt;right,lev); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You could avoid a bunch of do-nothing calls: &lt;br /&gt;&lt;br /&gt;      if (n-&gt;left) preorder(n-&gt;left,lev); &lt;br /&gt;      if (n-&gt;right) preorder(n-&gt;right,lev); &lt;br /&gt;&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eric sosman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt; "How good" is a slippery question, because there are many criteria of goodness, some of them in conflict.  So I'll offer observations, not judgements. &lt;br /&gt;&lt;br /&gt;1) It will fail badly on a tree with more than a hundred levels.  Do such trees really exist?  Try this: write a program to build a binary search tree from an input stream of words, then feed it a list of ten thousand words -- in alphabetical order. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2) Even if arrlev[] is made larger, the function is likely to fail on very tall trees (or degenerate trees, as above). Remember, each function invocation needs to "remember" where it was called from so it can return there.  The amount of space &lt;br /&gt;set aside for this bookkeeping is often rather limited, and if the recursive calls go too deep they may exhaust it. &lt;br /&gt;&lt;br /&gt;3) You might gain some speed by handling the left branch (say) in a loop while making recursive calls only for the right branches. &lt;br /&gt;&lt;br /&gt;4) You might gain still more speed by using recursion only when you encounter a node where both the left and right branches are non-NULL.  This also offers some defense against degeneracy. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5) Adding `const' to the first argument might be nice. &lt;br /&gt;&lt;br /&gt;6)Adding some commentary about what the function does and how to use it might be even nicer. &lt;br /&gt;&lt;br /&gt;7)Passing a pointer to the totals array instead of using the global variable&lt;br /&gt; arrlev[] might be nice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2463013139449488858?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2463013139449488858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2463013139449488858' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2463013139449488858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2463013139449488858'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/no-of-nodes-in-each-level-of-binary.html' title='no: of nodes in each level of binary tree'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-5577529356621789010</id><published>2008-05-07T12:39:00.000-07:00</published><updated>2008-06-09T22:31:43.198-07:00</updated><title type='text'>example program</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;can any one give a example program  where recursive version is faster&lt;br /&gt;than iterative version ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;rahul&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Recursive programs can be faster than the iterative versions when the only changes you have introduced in the iterative version is saving and restoring states. The system is of course faster in performing push and pop as it simply means issuing 1 or 2 machine instructions.In case of factorials, the stack frame is completely unnecessary. So the iterative version is magnitudes faster than the recursive one.&lt;br /&gt;&lt;br /&gt;Towers of Hanoi is faster in recursive version than the iterative one.I am not sure about the quick sort. I will have to profile it but surely the recursive version is more clear than the iterative one.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;bartc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:&lt;br /&gt;&lt;br /&gt;&gt; can any one give a example program  where recursive version is faster&lt;br /&gt;&gt; than iterative version ?&lt;br /&gt;&lt;br /&gt;For trivial programs there may or may not be examples where recursion is faster.&lt;br /&gt;&lt;br /&gt;But recursion is a natural fit for many kinds of programming which would be a pain to implement with iterative methods.&lt;br /&gt;&lt;br /&gt;Especially with making arrangements to save/restore complex data which may well end up slower than just using recursion. But even if recursion was slower, the difference would be minimal in a real application, while keeping the code much cleaner.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;richard heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Bartc said:&lt;br /&gt;&lt;br /&gt;&gt; aarklon wrote:&lt;br /&gt;&lt;br /&gt;&gt;&gt; can any one give a example program  where recursive version is faster&lt;br /&gt;&gt;&gt; than iterative version ?&lt;br /&gt;&lt;br /&gt;&gt; For trivial programs there may or may not be examples where recursion is&lt;br /&gt;&gt; faster.&lt;br /&gt;&lt;br /&gt;There is, however, no shortage of examples where recursion is /slower/.&lt;br /&gt;&lt;br /&gt;&gt; But recursion is a natural fit for many kinds of programming which would&lt;br /&gt;&gt; be a pain to implement with iterative methods.&lt;br /&gt;&lt;br /&gt;Right. We don't recurse for speed, but for clarity (where it /is/ clearer) - and even then only if the cost in terms of speed loss is more than adequately compensated by the gain in clarity.&lt;br /&gt;&lt;br /&gt;To take a famous example, the following code:&lt;br /&gt;&lt;br /&gt; unsigned long factorial(unsigned long n)&lt;br /&gt; {&lt;br /&gt;  return n &lt; 2 ? 1 : (n * factorial(n - 1));&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;is horribly inefficient compared to its iterative version (and more so,compared to the Stirling Approximation). In a production environment, it would be inappropriate. But in a teaching environment, it might well be considered a reasonable way to /illustrate/ recursion, given suitable "don't do factorials this way in Real Life" caveats.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;barry schwarz&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote&lt;br /&gt;&gt;can any one give a example program  where recursive version is faster&lt;br /&gt;&gt;than iterative version ?&lt;br /&gt;&lt;br /&gt;Primary concern: You need two versions of the program.  How do you confirm they are truly equivalent and that each is really coded for highest efficiency?&lt;br /&gt;&lt;br /&gt;Secondary concerns:  On which hardware?  Using which operating system? Using which compiler?  With what options?  Which measure of speed, CPU time or wall clock?&lt;br /&gt;&lt;br /&gt;Are you getting the hint that there is no general answer? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;pete&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Iterative mergesorts that I've seen for arrays,tend to split less evenly than the recursive versions do. When I race array sorting functions,I can't get any speed from the iterative mergesorts. I still haven't figured out how to mergesort a linked list iteratively.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;vamsi krishna ak&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Try doing a BFS (Breadth First Search) or DFS of a dense graph recursively and iteratively (using lists) you will see a lot of difference.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt; paul hseih&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote&lt;br /&gt;&gt; Can any one give a example program  where recursive version is faster&lt;br /&gt;&gt; than iterative version ?&lt;br /&gt;&lt;br /&gt;I can think of two:&lt;br /&gt;&lt;br /&gt;1) Return the ith term of a fibonacci.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;No, seriously.  Its a matter of *WHICH* recursive formula you use.There is a quadratic formula for {fib(n+1),fib(n)} in terms of {fib(floor(n/2)+1),fib(floor(n/2))} which means that you can calculate fib(n) in O(log(n)) steps (using recursion) instead of O(n) steps as is usually the case with the typical iterative solution.  For very large n in big integer systems this is, in fact, that fastest algorithm I know of for calculating fib(n).  Anywhere where the direct exponential formula can be used (when n is relatively small), tables can also be used and are tremendously faster.&lt;br /&gt;&lt;br /&gt;2) a challenge was recently posted&lt;br /&gt;there which asked how to output the nodes of a binary search tree in order without using any recursion or a growable stack/array.  My solution which did not modify the tree (imagine that the tree was a mapping of URLs or was in ROM or through a file system with no write permissions) took O(n*log(n)) time, and AFAIK, was not improved upon. However, the recursive solution takes O(n) time. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;chris thomasson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;IMVHO, it's not really a matter of whether recursion is faster than iteration, but which one is "safer" in practice... Recursion has a side-effect of blowing the stack on some platforms when the depth exceeds the stack size of the calling thread. This does not happen for iteration; here is an example: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I personally find that using recursion to traverse trees can be somewhat dangerous because certain trees can potentially blow the stack. To get around recursion, I tend to use an auxiliary node, and use that as a link into a traversal queue. Something like:&lt;br /&gt;&lt;br /&gt;&lt;pseudo-code&gt;&lt;br /&gt;_______________________________________________________________&lt;br /&gt;struct tnode {&lt;br /&gt;  struct tnode* left;&lt;br /&gt;  struct tnode* right;&lt;br /&gt;  struct tnode* next;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;/* Tree Iteration Support */&lt;br /&gt;struct tnode_iterq {&lt;br /&gt;  struct tnode* head;&lt;br /&gt;  struct tnode* tail;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void tnode_iterq_push(&lt;br /&gt; tnode_iterq* const _this,&lt;br /&gt; tnode* const node&lt;br /&gt;) {&lt;br /&gt;  if (node) {&lt;br /&gt;    node-&gt;next = NULL;&lt;br /&gt;    if (! _this-&gt;head) {&lt;br /&gt;      _this-&gt;head = node;&lt;br /&gt;    } else {&lt;br /&gt;      _this-&gt;tail-&gt;next = node;&lt;br /&gt;    }&lt;br /&gt;    _this-&gt;tail = node;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;tnode* tnode_iterq_pop(&lt;br /&gt; tnode_iterq* const _this&lt;br /&gt;) {&lt;br /&gt;  tnode* const node = _this-&gt;head;&lt;br /&gt;  if (node) {&lt;br /&gt;    if (! (_this-&gt;head = node-&gt;next)) {&lt;br /&gt;      _this-&gt;tail = NULL;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  return node;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Tree Iterator */&lt;br /&gt;void* tnode_iterate(&lt;br /&gt; tnode* const _this,&lt;br /&gt; void (*fp_iterate) (tnode*, void*),&lt;br /&gt; void* const state&lt;br /&gt;) {&lt;br /&gt;  unsigned count = 0;&lt;br /&gt;  tnode* node = _this;&lt;br /&gt;  tnode_iterq iterq = { NULL };&lt;br /&gt;  do {&lt;br /&gt;    tnode_iterq_push(&amp;iterq, node-&gt;left);&lt;br /&gt;    tnode_iterq_push(&amp;iterq, node-&gt;right);&lt;br /&gt;    fp_iterate(node, state);&lt;br /&gt;    ++count;&lt;br /&gt;  } while (! (node = tnode_iterq_pop(&amp;iterq)));&lt;br /&gt;  return state;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;_______________________________________________________________&lt;br /&gt;&lt;br /&gt;Now there is no chance of blowing the stack because all recursion is eluded... &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;chriss thomasson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;paul hseih wrote&lt;br /&gt;&lt;br /&gt;a challenge was recently posted&lt;br /&gt;&gt; there which asked how to output the nodes of a binary search tree in&lt;br /&gt;&gt; order without using any recursion or a growable stack/array.  My&lt;br /&gt;&gt; solution which did not modify the tree (imagine that the tree was a&lt;br /&gt;&gt; mapping of URLs or was in ROM or through a file system with no write&lt;br /&gt;&gt; permissions) took O(n*log(n)) time, and AFAIK, was not improved upon.&lt;br /&gt;&gt; However, the recursive solution takes O(n) time.&lt;br /&gt;&lt;br /&gt;Did your solution use something similar my technique: &lt;br /&gt;&lt;br /&gt;I basically add an auxiliary pointer per-node and use that as a link in a traversal queue. I believe that is easier than explicitly threading the tree. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;paul hseih&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No, mine did not augment or write to the tree at all.  It uses O(1) space: &lt;br /&gt;&lt;br /&gt;http://www.azillionmonkeys.com/qed/treeO1.c&lt;br /&gt;&lt;br /&gt;In any event, the recursive solution is *faster* than this which is what the OP was looking for.  I just happen to be able to demonstrate that "this" even existed. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;rahul&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So basically if we try simply to convert a recursive solution to iterative by manually creating a stack frame and simulating function calls, the resulting code is both ugly and slow. But if obvious optimizations can be done for the stack frame, and in some cases it is even completely eliminated ( factorial  ), then the iterative code is more efficient. As per my understanding, there are various algorithms in which recursive solutions are faster - towers of hanoi, BFS, DFS to name a few.&lt;br /&gt;&lt;br /&gt;The recursive solution for X is faster than iterative does not necessarily mean it is faster. It may mean that an optimized iterative algorithm is yet to be written. A bit off the topic, but many a times tail recursion (where applicable) significantly increases the execution speed. I think the choice between recursive and iterative approach is highly situation dependent and there is no right answer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-5577529356621789010?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/5577529356621789010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=5577529356621789010' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5577529356621789010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5577529356621789010'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/casting-out-nines.html' title='example program'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6016741890031519581</id><published>2008-05-07T11:18:00.000-07:00</published><updated>2008-12-25T07:17:03.470-08:00</updated><title type='text'>Decision Tree</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SVOj3zDyv2I/AAAAAAAAAzY/t3RBqGjUuVU/s1600-h/Screenshot1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SVOj3zDyv2I/AAAAAAAAAzY/t3RBqGjUuVU/s320/Screenshot1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5283746966829973346" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6016741890031519581?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6016741890031519581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6016741890031519581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6016741890031519581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6016741890031519581'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/palindromic-numbers.html' title='Decision Tree'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SVOj3zDyv2I/AAAAAAAAAzY/t3RBqGjUuVU/s72-c/Screenshot1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1219971272176883439</id><published>2008-05-05T21:57:00.001-07:00</published><updated>2008-05-05T22:02:10.180-07:00</updated><title type='text'>Look for SOAP implementation for C (not C++)</title><content type='html'>&lt;span style="font-weight:bold;"&gt;swen&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Could anyone point me to a SOAP implementation for C? What I would like to do is call out to Web Services from C, and may be later also the reverse- expose C functions as a Web Service...At the moment we are using GNU C on a UNIX system. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;christopher browne&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;gSOAP is the one that is being maintained at present...  It speaks both C and C++.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;let name="aa454" and tld="freenet.carleton.ca" in name ^ "@" ^ tld;;&lt;br /&gt;&lt;br /&gt;http://cbbrowne.com/info/soap.html&lt;br /&gt;&lt;br /&gt;"...you  might  as well  skip  the  Xmas  celebration completely,  and instead  sit  in  front  of  your  linux  computer  playing  with  the all-new-and-improved linux kernel version." -- Linus Torvalds&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1219971272176883439?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1219971272176883439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1219971272176883439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1219971272176883439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1219971272176883439'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/look-for-soap-implementation-for-c-not.html' title='Look for SOAP implementation for C (not C++)'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-621762130316258861</id><published>2008-05-05T21:45:00.000-07:00</published><updated>2008-05-05T21:50:53.885-07:00</updated><title type='text'>web services with c</title><content type='html'>&lt;span style="font-weight:bold;"&gt;h&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Is it possible to consume web services with c? If not, what other languages would be needed to accomplish this? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;richard hethfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sure, given an appropriate library.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;pawel lesik&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;yes it is possible for example with gSOAP &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;&lt;br /&gt;h&lt;/span&gt;&lt;br /&gt;what about http://www.sqldata.com/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;flash gordon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I can definitely say that gSOAP is not always the answer, and C is not always the best language.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;michael wojcik&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes, if by "consume" you mean either "invoke" or "provide".  Both are possible in C.  They may even be possible entirely in portable C,given a sufficiently flexible definition of "web services" or a sufficiently generous implementation.&lt;br /&gt;&lt;br /&gt;For most applications, however, you would have to use facilities outside the C standard (which is what we discuss here), such as an API for network communications.&lt;br /&gt;&lt;br /&gt;I suggest that rather than reinventing the wheel, you look for a C web services client or server implementation that suits your needs,or at least for libraries that provide facilities such as HTTP and XML parsing&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;michael wojcik&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Flash Gordon writes:&lt;br /&gt;&lt;br /&gt;&gt; The C language has absolutely no abilities for&lt;br /&gt;&gt; the most fundamental things required for a web service, such as&lt;br /&gt;&gt; communications over a network.&lt;br /&gt;&lt;br /&gt;This is arguably true (there's a possible quibble over "fundamental" and "required"), but not necessarily relevant.  While network communication is "fundamental" to web services, that does not mean that a provider or consumer of web services need be responsible for network communications.&lt;br /&gt;&lt;br /&gt;Consider, for example, a portable C program running in an environment where stdin and stdout are the required network communications channel.  Such environments are actually very common: inetd and its analogues, CGI programs, and so forth.  (There are client-side examples as well.)&lt;br /&gt;&lt;br /&gt;It might not be practical, for most applications, to provide or consume web services entirely in portable C, in an environment where this is possible; but I'd like to avoid the false generalization that any task (such as using web services) which is associated with some&lt;br /&gt;facility outside the C standard therefore cannot be done in portable C.  Even here we must entertain various unguaranteed expectations about the execution environment, QoI, and so forth.&lt;br /&gt;&lt;br /&gt;I'm of the opinion that the original question itself was marginally topical (if considered as "can this be done in standard C?"), but answers other than redirections to implementation-specific groups or those that describe what standard C does not provide (eg network communications, XML parsing, etc) would be off-topic.  h's claim of topicality for the larger question ("how can this be done in C?") on the grounds that all C programs are topical is spurious, of course, for the reasons you outline and we're all familiar with, but it's legitimate (again, IMO) for someone to ask here whether some task *can* be accomplished in standard C.  And in that event I for one would prefer to see responses that are a bit more cautious in delimiting what is and is not covered by the standard language.&lt;br /&gt;&lt;br /&gt;An ideal response, in my opinion, might be along the lines of "it is possible, in some environments, to consume web services in a portable C program, which is what we discuss here; but in practice you are likely to want to use implementation- and environment-specific&lt;br /&gt;features and facilities, and you should ask about those in a news-group relevant to your platform".  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The manner in which the network communications channel is associated with stdin and stdout is implementation-specific and non-portable -but of course the manner in which *anything* is associated with stdin and stdout is implementation-specific and non-portable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To be perhaps a bit clearer:&lt;br /&gt;&lt;br /&gt;Standard C has absolutely no support for networking.  That doesn't mean it's impossible to write networking code in C (obviously a great deal of networking code is written in C); it just means it's impossible to write networking code in C without using system-specific extensions.&lt;br /&gt;&lt;br /&gt;If you can arrange for the environment in which your program runs to associate any necessary network communications channels with your program's stdin and/or stdout, you may be able to write your program in 100% standard C, perhaps even strictly conforming C. But it's not clear that it would be worth the effort.  You're going to have to do *some* system-specific work regardless; keeping the system dependencies entirely out of your C program may or may not make sense.&lt;br /&gt;&lt;br /&gt;It should be possible to write networking code that's not 100% portable C, but that's probably as portable as you need it to be.The POSIX standard, though it's off-topic here, provides facilities for networking and a number of other operating system interfaces.If your code is expected to run only on POSIX-compliant systems, you can use the POSIX-defined interfaces and your program will still be "portable enough".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-621762130316258861?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/621762130316258861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=621762130316258861' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/621762130316258861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/621762130316258861'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/05/web-services-with-c.html' title='web services with c'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2567926195279093794</id><published>2008-04-27T00:24:00.000-07:00</published><updated>2008-04-27T00:41:27.038-07:00</updated><title type='text'>ISBN 0-07-044759-4</title><content type='html'>I was going through the book "Test your skills in C" by Thamarai selvi and R murugesan, publisheb by Tata Mcgraw-Hill,ISBN 0-07-044759-4 , the following are from this book, now my question is to what extent the following are true..??? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1) a function with no action is allowed and is known as dummy function &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2) (int(*(*)[3])(char*))ptr  is the correct way to cast ptr to a pointer to a 3 element array of function pointers with a return value of int and a single parameter of a pointer to char &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3)how could stderr be re directed from within a program to force all error messages to be written to the end of the text file "error.log" instead of location specified by the operating system &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a) stderr = fopen("error.log","w"); &lt;br /&gt;b) freopen("error.log","a",stderr); &lt;br /&gt;c) stderr = freopen(stderr,"a","error.log"); &lt;br /&gt;d) stderr = fopen("error.log","a"); &lt;br /&gt;&lt;br /&gt;the answer is given as d option &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4) #include &lt; stdlib.h &gt; &lt;br /&gt;   #include &lt; stdio.h &gt; &lt;br /&gt;   char *format="%d"; &lt;br /&gt;   void func(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   int main(void) &lt;br /&gt;   { &lt;br /&gt;     int x; &lt;br /&gt;     func(scanf,&amp;x); &lt;br /&gt;     printf("%d\n",x); &lt;br /&gt;&lt;br /&gt;     return EXIT_SUCCESS; &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;referring to the sample code given above, which of the following would be correct implementation for func ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; a) void func( int (*y)(const char*,...),int* x) &lt;br /&gt;    { (*y)(format,x); } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; b) void func( int (*y)(const char*,...),int* x) &lt;br /&gt;    { (*y)(format,&amp;x); } &lt;br /&gt;&lt;br /&gt; answer is given as a option&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;a function with no action is allowed and is known as dummy function&lt;/em&gt;&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;True. Sometimes they are also called as stub functions. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;flash gordon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;It is true that it is allowed. It is also true that such functions are often known (by me at least) as dummy functions. However, whether they &lt;br /&gt;are called dummy functions is nothing to do with C. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Malcom mclean&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;You mean the standard doesn't define anything known as the "dummy" function. &lt;br /&gt;However it is implicit in that &lt;br /&gt;&lt;br /&gt;void dummy(void) &lt;br /&gt;{ } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;is allowed by C rules of grammar. It wasn't a necessary decision to allow functions with no code in the body at all. &lt;br /&gt;&lt;br /&gt;Dummy functions differ from stub functions. A dummy function does nothing, a stub function returns valid but trival data. For instance if you wanted to read a bar code, but had no barcode reader, you might write a stub function &lt;br /&gt;&lt;br /&gt;int readbarcode(char *code) &lt;br /&gt;{ &lt;br /&gt;   strcpy(code, "123456789012345"); &lt;br /&gt;   return 0; &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;as a placeholder until the real reader arrives.Both are perfectly valid C programming concepts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;(int(*(*)[3])(char*))ptr  is the correct way to cast ptr to a pointer to a 3 element array of function pointers with a return value of int and a single parameter of a pointer to char &lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Flash gordon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I can't think of a good reason for doing such a thing. If there ever was a good reason I would not do it like that (and would reject anything like that in a code review) since it can be made far clearer by using a typedef for the function type (or function pointer type if you prefer).&lt;br /&gt;&lt;br /&gt;how could stderr be re directed from within a program to force all error messages to be written to the end of the text file "error.log" instead of location specified by the operating system &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a) stderr = fopen("error.log","w"); &lt;br /&gt;b) freopen("error.log","a",stderr); &lt;br /&gt;c) stderr = freopen(stderr,"a","error.log"); &lt;br /&gt;d) stderr = fopen("error.log","a"); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Wrong. The correct option is (b). The pre-defined streams need not be lvalues. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;flash gordon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;stderr need not be a modifiable lvalue. I.e. you may not be able to do the assignment in d. According to the standard the primary use of freopen is to change the file associated with stdin/out/err for this very reason! So that leave b as the only possibility, so if the book really does say d it is wrong. &lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   #include &lt; stdlib.h &gt; &lt;br /&gt;   #include &lt; stdio.h &gt; &lt;br /&gt;   char *format="%d"; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   void func(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   int main(void) &lt;br /&gt;   { &lt;br /&gt;     int x; &lt;br /&gt;     func(scanf,&amp;x); &lt;br /&gt;     printf("%d\n",x); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     return EXIT_SUCCESS; &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  referring to the sample code given above, which of the following &lt;br /&gt;would be correct implementation &lt;br /&gt;  for func ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; a) void func( int (*y)(const char*,...),int* x) &lt;br /&gt;    { (*y)(format,x); } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; b) void func( int (*y)(const char*,...),int* x) &lt;br /&gt;    { (*y)(format,&amp;x); } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; answer is given as a option &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Yes. That's right. Note though that the call could as well have been: &lt;br /&gt;&lt;br /&gt;y(format, x); or   (****y)(format, x); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;flash gordon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Of the two, a is the only possible valid answer (the correct answer depends on the version of the C standard in use). However, I don't like the code anyway :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2567926195279093794?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2567926195279093794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2567926195279093794' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2567926195279093794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2567926195279093794'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/isbn-0-07-044759-4.html' title='ISBN 0-07-044759-4'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7615418294112919495</id><published>2008-04-25T06:01:00.000-07:00</published><updated>2008-04-25T06:05:26.962-07:00</updated><title type='text'>printf("%d",*(&amp;ptr2 + 2))</title><content type='html'>&lt;strong&gt;sophia&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;why in the following program &lt;br /&gt; #include &lt; stdio.h &gt; &lt;br /&gt; #include &lt; stdlib.h &gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void) &lt;br /&gt; { &lt;br /&gt;   int x[] = {99,2,3,4,5}; &lt;br /&gt;   int *ptr,**ptr2; &lt;br /&gt;&lt;br /&gt;   ptr  = x; &lt;br /&gt;   ptr2 = &amp;ptr; &lt;br /&gt;   printf("%d",*(&amp;ptr2 + 2)); &lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS; &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;printf("%d",*(&amp;ptr2 + 2)); is printing the first element of the array x ? can anybody explain ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ian collins&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Where do people find these contrived examples? &lt;br /&gt;&lt;br /&gt;The answer is luck.I just happens that's the way the variables are laid out in memory.Try building 64 bit and see what you get then. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;sophia&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There is something more than luck, that is my conclusion. &lt;br /&gt;&lt;br /&gt;I tried changing the value of x[0] to different values but still it will print the o/p correctly. &lt;br /&gt;&lt;br /&gt;Has it any thing to do with the compiler ? &lt;br /&gt;I checked this program on lcc-win32 compiler &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;What it prints is purely by chance. &lt;br /&gt;Did your compiler not produce a warning? &lt;br /&gt;&lt;br /&gt;What is the type of &amp;ptr2? It's int ***. What is the type of (&amp;ptr2 +2). Again the same. Then what's the type of *(&amp;ptr2 + 2)? It's int **.What type does %d expect. It expects an int. &lt;br /&gt;&lt;br /&gt;What you want is:printf("%d\n", **ptr2); &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&gt; There is something more than luck, that is my conclusion. &lt;br /&gt;&lt;br /&gt;Your conclusion is wrong. What it prints is purely by chance, since there is a type discrepancy between what printf expects and what it gets. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt; I tried changing the value of x[0] to different values but still &lt;br /&gt;&gt; it will print the o/p correctly. &lt;br /&gt;&lt;br /&gt;That's irrelevant. &lt;br /&gt;&lt;br /&gt;&gt; Has it any thing to do with the compiler ? &lt;br /&gt;&lt;br /&gt;Certainly your output, because your program invokes undefined behaviour,is likely to be specific to your implementation or even specific to each run of the program&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ian collins&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&gt; There is something more than luck, that is my conclusion. &lt;br /&gt;&gt; I tried changing the value of x[0] to different values but still &lt;br /&gt;&gt; it will print the o/p correctly. &lt;br /&gt;&lt;br /&gt;The luck is in the memory layout, not the values. The address of &amp;ptr2 + 2 just happens to be the address of x[0]. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt; Has it any thing to do with the compiler ? &lt;br /&gt;&lt;br /&gt;Everything, memory layout is compiler and platform specific, although most 32 bit compilers on x86 probably use the same layout. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt;  I don't have a 64 bit compiler &lt;br /&gt;Every home should have one :) &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;the question is broken and the program is undefined according to the language standard.  Even if it were to be assumed that the array 'x' starts 2 * sizeof &amp;ptr2 bytes after &amp;ptr2, the program is still broken because the printf call is incorrect.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7615418294112919495?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7615418294112919495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7615418294112919495' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7615418294112919495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7615418294112919495'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/printfd-2.html' title='printf(&quot;%d&quot;,*(&amp;ptr2 + 2))'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-885172215350121389</id><published>2008-04-25T05:52:00.000-07:00</published><updated>2008-04-25T05:53:35.891-07:00</updated><title type='text'>#define vs typedef</title><content type='html'>The right way to think about typedef as being a complete encapsulated type - you can't add  to it after you have declared it.&lt;br /&gt;&lt;br /&gt;ex:-&lt;br /&gt;&lt;br /&gt;         #define peach int&lt;br /&gt;          unsigned peach i;   /*works fine*/&lt;br /&gt;&lt;br /&gt;         typedef int banana ;&lt;br /&gt;         unsigned banana i; /*illegal*/&lt;br /&gt;&lt;br /&gt;  a typedef'd name provides the type for every declarator in a declaration&lt;br /&gt;&lt;br /&gt;  Ex:-&lt;br /&gt;&lt;br /&gt;          #define int_ptr int*&lt;br /&gt;           int_ptr chalk, cheese;&lt;br /&gt;&lt;br /&gt; after macro expansion, the second line effectively becomes&lt;br /&gt;  int* chalk,cheese;&lt;br /&gt;&lt;br /&gt;In contrast a typedef like this:&lt;br /&gt;&lt;br /&gt; typedef char* char_ptr;&lt;br /&gt; char_ptr bentley,rolls_royce;&lt;br /&gt;&lt;br /&gt;declares both bentley and rolls_royce to be the same . the name on the front is different, but they are both a pointer to a char.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-885172215350121389?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/885172215350121389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=885172215350121389' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/885172215350121389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/885172215350121389'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/define-vs-typedef.html' title='#define vs typedef'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-4335060069363744979</id><published>2008-04-22T20:38:00.000-07:00</published><updated>2008-04-25T05:31:37.204-07:00</updated><title type='text'>simple AVL tree program</title><content type='html'>/*Program for insertion in AVL tree*/ &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #include &lt; stdio.h &gt; &lt;br /&gt; #include &lt; stdlib.h &gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #define FALSE 0 &lt;br /&gt; #define TRUE  1 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; typedef struct node &lt;br /&gt; { &lt;br /&gt;   int val; &lt;br /&gt;   int balfact; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   struct node* left; &lt;br /&gt;   struct node* right; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; }node; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; node* buildtree(node*,int,int*); &lt;br /&gt; node* allocate(int); &lt;br /&gt; void display(node*); &lt;br /&gt; void deltree(node*); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void) &lt;br /&gt; { &lt;br /&gt;   node* avl = NULL; &lt;br /&gt;   int h; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   avl = buildtree(avl,20,&amp;h); &lt;br /&gt;   avl = buildtree(avl,6,&amp;h); &lt;br /&gt;   avl = buildtree(avl,5,&amp;h); &lt;br /&gt;   avl = buildtree(avl,29,&amp;h); &lt;br /&gt;   avl = buildtree(avl,12,&amp;h); &lt;br /&gt;   avl = buildtree(avl,25,&amp;h); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   printf("\n AVL TREE\n"); &lt;br /&gt;   display(avl); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   printf("\n checking root value %d", avl-&gt; val); &lt;br /&gt;   printf("\n checking root balance value %d", avl-&gt; balfact); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   deltree(avl); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS; &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; node* buildtree(node* root,int data,int *h) &lt;br /&gt; { &lt;br /&gt;   node* n1,*n2; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   if(!root) &lt;br /&gt;   { &lt;br /&gt;      root = allocate(data); &lt;br /&gt;      *h = TRUE; &lt;br /&gt;      return root; &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   if(data &lt; root -&gt; val) &lt;br /&gt;   { &lt;br /&gt;     root -&gt; left = buildtree(root -&gt; left,data,h); &lt;br /&gt;     /*if left sub tree is higher*/ &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     if(*h) &lt;br /&gt;      { &lt;br /&gt;       switch(root -&gt; balfact) &lt;br /&gt;       { &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;           case -1: &lt;br /&gt;                    root -&gt; balfact = 0; &lt;br /&gt;                    *h = FALSE; &lt;br /&gt;                    break; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;           case  0: &lt;br /&gt;                   root -&gt; balfact = 1; &lt;br /&gt;                   break; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;           case 1: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                   n1 = root -&gt; left; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                   if(n1-&gt; balfact == 1) &lt;br /&gt;                   { &lt;br /&gt;                     printf("\n Right rotation along %d", root -&gt; val); &lt;br /&gt;                     root -&gt; left    = n1 -&gt; right; &lt;br /&gt;                     n1   -&gt; right   = root; &lt;br /&gt;                     root -&gt; balfact = 0; &lt;br /&gt;                     root = n1; &lt;br /&gt;                   } &lt;br /&gt;                     else &lt;br /&gt;                     { &lt;br /&gt;                       printf("\n Double rotation ...left along %d",n1-&gt; val); &lt;br /&gt;                       n2 = n1 -&gt; right; &lt;br /&gt;                       n1 -&gt; right = n2 -&gt; left; &lt;br /&gt;                       n2 -&gt; left  = n1; &lt;br /&gt;                       root -&gt; left = n2 -&gt; right; &lt;br /&gt;                       n2 -&gt; right = root; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                       if(n2 -&gt; balfact == 1) &lt;br /&gt;                       root -&gt; balfact = -1; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                       else &lt;br /&gt;                       root -&gt; balfact = 0; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                       if(n2 -&gt; balfact == -1) &lt;br /&gt;                         n1 -&gt; balfact = 1; &lt;br /&gt;                       else &lt;br /&gt;                         n1-&gt; balfact = 0; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                       root = n2; &lt;br /&gt;                     } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                      root -&gt; balfact = 0; &lt;br /&gt;                      *h = FALSE; &lt;br /&gt;                      break; &lt;br /&gt;                 } &lt;br /&gt;           } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   if(data &gt; root -&gt; val) &lt;br /&gt;   { &lt;br /&gt;      /*if the right sub tree is higher*/ &lt;br /&gt;         root -&gt; right = buildtree(root -&gt; right,data,h); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     if(*h) &lt;br /&gt;      { &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       switch(root -&gt; balfact) &lt;br /&gt;        { &lt;br /&gt;                   case  0: &lt;br /&gt;                                root -&gt; balfact = -1; &lt;br /&gt;                                break; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                   case  1: &lt;br /&gt;                                root -&gt; balfact = 0; &lt;br /&gt;                                *h = FALSE; &lt;br /&gt;                                break; &lt;br /&gt;                   case -1: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                               n1 = root -&gt; right; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                             if(n1 -&gt; balfact == -1) &lt;br /&gt;                             { &lt;br /&gt;                               printf("\n Left rotation along %d",root -&gt; val); &lt;br /&gt;                               root -&gt; right   = n1 -&gt; left; &lt;br /&gt;                               n1 -&gt; left      = root; &lt;br /&gt;                               root-&gt; balfact  = 0; &lt;br /&gt;                               root = n1; &lt;br /&gt;                              } &lt;br /&gt;                              else &lt;br /&gt;                              { &lt;br /&gt;&lt;br /&gt;                               printf("Double rotation right along %d ", n1-&gt; val); &lt;br /&gt;                               n2            = n1 -&gt; left; &lt;br /&gt;                               n1 -&gt; left    = n2 -&gt; right; &lt;br /&gt;                               n2 -&gt; right   = n1; &lt;br /&gt;                               root -&gt; right = n2 -&gt; left; &lt;br /&gt;                               n2 -&gt; left    = root; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                               if(n2 -&gt; balfact == -1) &lt;br /&gt;                                      root -&gt; balfact  = 1; &lt;br /&gt;                               else &lt;br /&gt;                                      root -&gt; balfact  = 0; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                                if(n2 -&gt; balfact == 1) &lt;br /&gt;                                           n1 -&gt; balfact == -1; &lt;br /&gt;                                else &lt;br /&gt;                                           n1 -&gt; balfact = 0; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                                root = n2; &lt;br /&gt;                             } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                                 root -&gt;balfact=0; &lt;br /&gt;                                 *h = FALSE; &lt;br /&gt;                } &lt;br /&gt;&lt;br /&gt;         } &lt;br /&gt;&lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   return root; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void display(node* root) &lt;br /&gt; { &lt;br /&gt;   if(root) &lt;br /&gt;   { &lt;br /&gt;     display(root -&gt; left); &lt;br /&gt;     printf("\t %d",root -&gt; val); &lt;br /&gt;     display(root -&gt; right); &lt;br /&gt;   } &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void deltree(node* root) &lt;br /&gt; { &lt;br /&gt;   if(root) &lt;br /&gt;   { &lt;br /&gt;     deltree(root -&gt; left); &lt;br /&gt;     deltree(root -&gt; right); &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    free(root); &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; node* allocate(int val) &lt;br /&gt; { &lt;br /&gt;   node *temp; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   temp = malloc(sizeof(*temp)); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   if(!temp) &lt;br /&gt;   { &lt;br /&gt;     printf("\nMemory allocation failed\ngoing to exit"); &lt;br /&gt;     exit(1); &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   temp -&gt; val     = val; &lt;br /&gt;   temp -&gt; left    = NULL; &lt;br /&gt;   temp -&gt; right   = NULL; &lt;br /&gt;   temp -&gt; balfact = 0; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   return temp; &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;_uacct = "UA-4163235-1";&lt;br /&gt;urchinTracker();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-4335060069363744979?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/4335060069363744979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=4335060069363744979' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4335060069363744979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4335060069363744979'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/simple-avl-tree-program.html' title='simple AVL tree program'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2786281629134887311</id><published>2008-04-20T07:36:00.000-07:00</published><updated>2008-04-20T07:44:34.903-07:00</updated><title type='text'>memset o/p not correct</title><content type='html'>&lt;strong&gt;aarklon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The following is actually a part of the pattern matching program which I tried ,memset is not setting the entire integer array with -1 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #include &lt; string.h &gt; &lt;br /&gt; #include &lt; stdio.h &gt; &lt;br /&gt; #include &lt; stdlib.h &gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void) &lt;br /&gt; { &lt;br /&gt;   int maxpat[80],i; &lt;br /&gt;   memset(maxpat,-1,80); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   for(i=0;i&lt;80;i++) &lt;br /&gt;   printf("%d\t",maxpat[i]); &lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS; &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;but i am getting o/p as &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-1      -1      -1      -1      -1      -1      -1      -1 &lt;br /&gt;-1      -1 &lt;br /&gt;-1      -1      -1      -1      -1      -1      -1      -1 &lt;br /&gt;-1      -1 &lt;br /&gt;-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086 &lt;br /&gt;-370086 -370086 &lt;br /&gt;-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086 &lt;br /&gt;-370086 -370086 &lt;br /&gt;-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086 &lt;br /&gt;-370086 -370086 &lt;br /&gt;-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086 &lt;br /&gt;-370086 -370086 &lt;br /&gt;-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086 &lt;br /&gt;-370086 -370086 &lt;br /&gt;-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086 &lt;br /&gt;-370086 -370086 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"D:\siju\lcc6\noisedisp.exe" &lt;br /&gt;Return code 0 &lt;br /&gt;Execution time 0.048 seconds &lt;br /&gt;Press any key to continue... &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;why is this so..???? &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ian collins&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;You are only setting the first 80 bytes of the the array, not 80 ints. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Bartc&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;You're setting 80 bytes. The array is bigger than that (80*sizeof(int)).&lt;br /&gt;Try:  memset(maxpat,-1,sizeof maxpat); &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Flash gordon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Check the definition of memset in your reference book, it sets a specified number of *bytes*. This also means that having corrected the error (sizeof *maxpat is your friend) it won't be portable to implementations using 1s complement or sign-magnitude if you can find such an implementation. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard tobin&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Unless you really on the machines being 2s-complement, which is true of all general-purpose computers today. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CBFalconer&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What's the point of the foolishness, when: &lt;br /&gt;&lt;br /&gt;  #define MPSIZE 80 &lt;br /&gt;  #define VALUE  -1 &lt;br /&gt;  int     maxpat[MPSIZE], i; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; MPSIZE; i++) maxpat[i] = VALUE; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;handles it accurately and portably, doesn't care about what VALUE is, and preserves the value of MPSIZE for any other uses.  Note that the bit of code above doesn't have to be in the scope of maxpat, rather it can receive it as a parameter. &lt;br /&gt;&lt;br /&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;_uacct = "UA-4163235-1";&lt;br /&gt;urchinTracker();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2786281629134887311?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2786281629134887311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2786281629134887311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2786281629134887311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2786281629134887311'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/memset-op-not-correct.html' title='&lt;strong&gt;memset o/p not correct&lt;/strong&gt;'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-4740343934743005596</id><published>2008-04-19T14:35:00.000-07:00</published><updated>2008-04-19T14:36:07.347-07:00</updated><title type='text'>pattern matching</title><content type='html'>/*program to find the maximum matching pattern in the string*/&lt;br /&gt;&lt;br /&gt; #include &lt; string.h &gt;&lt;br /&gt; #include &lt; stdio.h &gt;&lt;br /&gt; #include &lt; stdlib.h &gt;&lt;br /&gt;&lt;br /&gt; void findmaxpat(char*,char*,int*);&lt;br /&gt; void printmaxpat(char*,int*);&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   char s[80];&lt;br /&gt;   char pat[80];&lt;br /&gt;   int maxpat[80];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   memset(maxpat,-1,80);&lt;br /&gt;&lt;br /&gt;   printf("\n Enter the main string:: ");&lt;br /&gt;   gets(s);&lt;br /&gt;&lt;br /&gt;   while(*s)&lt;br /&gt;   {&lt;br /&gt;     printf("\n Enter the pattern to be searched:: ");&lt;br /&gt;     gets(pat);&lt;br /&gt;&lt;br /&gt;     findmaxpat(s,pat,maxpat);&lt;br /&gt;     printmaxpat(s,maxpat);&lt;br /&gt;&lt;br /&gt;  printf("\n Enter the main string:: ");&lt;br /&gt;     gets(s);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void findmaxpat(char* s,char* pat,int* maxpat)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   for(i=0;*s &amp;&amp; *pat;i++,s++)&lt;br /&gt;&lt;br /&gt;   if(*s == *pat)&lt;br /&gt;   *maxpat++ = i,pat++;&lt;br /&gt;&lt;br /&gt;   if(!*pat)&lt;br /&gt;    puts("whole pattern found...");&lt;br /&gt;&lt;br /&gt;   else&lt;br /&gt;     printf("pattern not found in the string ");&lt;br /&gt;&lt;br /&gt;   *maxpat = -1;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void printmaxpat(char* s,int* maxpat)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;    char *temp = s;&lt;br /&gt;&lt;br /&gt; (*maxpat == -1)? printf("\"%s\"\n",s) :puts(s);&lt;br /&gt;&lt;br /&gt;    for(;*temp &amp;&amp; *maxpat != -1;++temp)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;      if(temp-s == *maxpat)&lt;br /&gt;      {&lt;br /&gt;     printf("^");&lt;br /&gt;     maxpat++;&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;     printf("%c",' ');&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;    puts("");&lt;br /&gt; }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-4740343934743005596?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/4740343934743005596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=4740343934743005596' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4740343934743005596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4740343934743005596'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/pattern-matching.html' title='pattern matching'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2899171442168400750</id><published>2008-04-19T10:14:00.000-07:00</published><updated>2008-12-22T21:31:40.190-08:00</updated><title type='text'>Pseudo-code for array implementation of  circular queue</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SVB3pV834ZI/AAAAAAAAAzQ/xFcfDEUDznA/s1600-h/Screenshot1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SVB3pV834ZI/AAAAAAAAAzQ/xFcfDEUDznA/s320/Screenshot1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5282853915056398738" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2899171442168400750?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2899171442168400750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2899171442168400750' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2899171442168400750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2899171442168400750'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/why-vista-still-sucks.html' title='Pseudo-code for array implementation of  circular queue'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SVB3pV834ZI/AAAAAAAAAzQ/xFcfDEUDznA/s72-c/Screenshot1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-9103869171407133974</id><published>2008-04-19T10:08:00.000-07:00</published><updated>2008-04-19T10:21:47.505-07:00</updated><title type='text'>why this does n't works</title><content type='html'>&lt;strong&gt;aarklon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt; #include&lt; stdio.h &gt; &lt;br /&gt; #include&lt; stdlib.h &gt; &lt;br /&gt; #include&lt; string.h &gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void) &lt;br /&gt; { &lt;br /&gt;    char *t[5]; /*= {"BASIC"};*/ &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    strcpy(t[0],"BASIC"); &lt;br /&gt;    printf("....%s",t[0]); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    return EXIT_SUCCESS; &lt;br /&gt; } &lt;br /&gt;/* i am getting segmentation violation in lcc compiler*/ &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;is not working whereas &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main(void) &lt;br /&gt; { &lt;br /&gt;    char *t[5] = {"BASIC"}; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    /*strcpy(t[0],"BASIC");*/ &lt;br /&gt;    printf("....%s",t[0]); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    return EXIT_SUCCESS; &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;is working ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Does this mean that while using strcpy the char pointer should &lt;br /&gt;always be initialized ...????? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;pereges&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;i guess the problem arises because you have not allocated any memory for the string. Probably you can try this because it seems to work for me: &lt;br /&gt;&lt;br /&gt; #include &lt; stdio.h &gt; &lt;br /&gt; #include &lt; stdlib.h &gt; &lt;br /&gt; #include &lt; string.h &gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void) &lt;br /&gt; { &lt;br /&gt;    char *t[5]; /*= {"BASIC"};*/ &lt;br /&gt;     int i; &lt;br /&gt;     i = strlen("BASIC"); &lt;br /&gt;    t[0] = malloc(i * sizeof(char)); &lt;br /&gt;     strcpy(t[0],"BASIC"); &lt;br /&gt;    printf("....%s",t[0]); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    return EXIT_SUCCESS; &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard heathfield&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;this call attempts to copy SIX bytes, but you only reserved five (assuming the malloc worked, which you didn't check) - so you've written into memory you don't own, and the behaviour of your program is now undefined. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;kenneth brody&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Isn't this second version perfectly well-defined?  Doesn't the line: &lt;br /&gt;&lt;br /&gt;char *t[5] = {"BASIC"}; &lt;br /&gt;&lt;br /&gt;mean: t is an array of 5 character pointers, the first one points to the literal "BASIC", and the rest are NULL and so the reference to t[0] means the string "BASIC"?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Barry schwarz&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Yes &lt;br /&gt;&gt;and so the reference to t[0] means the string "BASIC"? &lt;br /&gt;&lt;br /&gt;Yes but it might be better phrased as'"the string literal "BASIC"'. &lt;br /&gt;&lt;br /&gt;It is only well defined as long as there is no attempt to update the characters pointed to by t[0].  Any attempt to do so (as implied by the commented call to strcpy) invokes undefined behavior.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-9103869171407133974?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/9103869171407133974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=9103869171407133974' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9103869171407133974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9103869171407133974'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/aarklon-why-this-does-nt-works-include.html' title='&lt;strong&gt;why this does n&apos;t works&lt;/strong&gt;'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8092603226949864251</id><published>2008-04-19T00:24:00.000-07:00</published><updated>2008-04-19T00:26:06.693-07:00</updated><title type='text'>memory management using list</title><content type='html'>/*design a storage management scheme where all requests for memory are of the same size,say K. Write functions to free and allocate storage in this scheme*/&lt;br /&gt;&lt;br /&gt; #include &lt; stdio.h &gt;&lt;br /&gt; #include &lt; stdlib.h &gt;&lt;br /&gt;&lt;br /&gt; #define N 90&lt;br /&gt; #define K 10&lt;br /&gt; #define SUCCESS 0&lt;br /&gt; #define ERROR    -1&lt;br /&gt;&lt;br /&gt; typedef struct node&lt;br /&gt; {&lt;br /&gt;   void *ptr;&lt;br /&gt;   struct node* next;&lt;br /&gt;&lt;br /&gt; }node;&lt;br /&gt;&lt;br /&gt; struct head&lt;br /&gt; {&lt;br /&gt;   node *next;&lt;br /&gt;   char *bytes;&lt;br /&gt;&lt;br /&gt; }freelist;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void init();&lt;br /&gt; void memfree(void*);&lt;br /&gt; void *memalloc();&lt;br /&gt; void print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;   void *p1,*p2,*p3,*p4;&lt;br /&gt;&lt;br /&gt;   init();&lt;br /&gt;   printf("\n after init\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;   p1 = memalloc();&lt;br /&gt;   printf("\n after memalloc p1.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   p2 = memalloc();&lt;br /&gt;   printf("\n after memalloc p2.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   p3 = memalloc();&lt;br /&gt;   printf("\n after memalloc p3.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   p4 = memalloc();&lt;br /&gt;   printf("\n after memalloc p4.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;   memfree(p4);&lt;br /&gt;   printf("\n after memfree p4.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   memfree(p3);&lt;br /&gt;   printf("\n after memfree p3.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   memfree(p2);&lt;br /&gt;   printf("\n after memfree p2.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   memfree(p1);&lt;br /&gt;   printf("\n after memfree p1.....\n");&lt;br /&gt;   print();&lt;br /&gt;&lt;br /&gt;   free(freelist.bytes);&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void init()&lt;br /&gt; {&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   freelist.next  = NULL;&lt;br /&gt;   freelist.bytes = malloc(N);&lt;br /&gt;&lt;br /&gt;   for(i=N/(K-1);i &gt;=0;i--)&lt;br /&gt;   memfree(freelist.bytes + K*i);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void memfree(void *p)&lt;br /&gt; {&lt;br /&gt;   /*adds p to free list*/&lt;br /&gt;&lt;br /&gt;   node *temp;&lt;br /&gt;&lt;br /&gt;   if(!p)&lt;br /&gt;   return;&lt;br /&gt;&lt;br /&gt;   temp          = malloc(sizeof(*temp));&lt;br /&gt;   temp -&gt; ptr   = p;&lt;br /&gt;   temp -&gt; next  = freelist.next;&lt;br /&gt;   freelist.next = temp;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void print()&lt;br /&gt; {&lt;br /&gt;   node* temp;&lt;br /&gt;&lt;br /&gt;   puts("");&lt;br /&gt;   for(temp = freelist.next;temp;temp = temp -&gt; next)&lt;br /&gt;   printf("%u \t",temp -&gt; ptr);&lt;br /&gt;&lt;br /&gt;   puts("");&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void* memalloc()&lt;br /&gt; {&lt;br /&gt;   void *p;&lt;br /&gt;   node *temp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   if(freelist.next == NULL)&lt;br /&gt;    return NULL;&lt;br /&gt;&lt;br /&gt;   temp = freelist.next;&lt;br /&gt;      p = temp -&gt; ptr;&lt;br /&gt;&lt;br /&gt;   freelist.next = freelist.next-&gt;next;&lt;br /&gt;   free(temp);&lt;br /&gt;&lt;br /&gt;   return p;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;_uacct = "UA-4163235-1";&lt;br /&gt;urchinTracker();&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8092603226949864251?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8092603226949864251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8092603226949864251' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8092603226949864251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8092603226949864251'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/memory-management-using-list.html' title='memory management using list'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8005563524278529563</id><published>2008-04-16T09:23:00.000-07:00</published><updated>2008-04-16T09:38:20.803-07:00</updated><title type='text'>pointer normalization</title><content type='html'>&lt;strong&gt;sophia&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;can any one explain what is meant by pointer normalization given here:- &lt;br /&gt;http://c-faq.com/ansi/norml.html &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard heathfield&lt;/strong&gt;&lt;br /&gt;It is possible for a pointer value to have more than one object representation. If p1 and p2 are two pointers to the same object, but with different object representations, then p1 == p2 is required to yield 1, so the implementation must (behave as if to) supply code to "normalise" the pointer values used in the comparison - i.e. to convert one or the other or both to a common form. (This was perfectly common in MS-DOS days.) &lt;br /&gt;&lt;br /&gt;Note that the same requirement (of identifying the equality of those two pointers) is not imposed on memcmp(&amp;p1, &amp;p2, sizeof p1). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;sophia&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Object in C means region of data storage isn't it ? &lt;br /&gt;i am not getting your point,same object with different representations ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;kenneth brody&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Consider, for example, "real mode" on an x86 CPU.  On that particular platform, addresses are represented by a 16-bit segment and a 16-bit offset.  (The physical address is segment*16+offset.)  Using this particular architecture, the following segment/offset pairs all point to the same physical address: &lt;br /&gt;&lt;br /&gt;    1234:0000 &lt;br /&gt;    1230:0040 &lt;br /&gt;    1200:0340 &lt;br /&gt;    1000:2340 &lt;br /&gt;and even &lt;br /&gt;    1111:1230 &lt;br /&gt;    0235:FFF0 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard heathfield&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Consider MS-DOS's 20-bit pointers, where logical addresses are described by &lt;br /&gt;two 16-bit values, called "segment" and "offset" respectively. To get the &lt;br /&gt;physical address, we left-shift the segment value by four bits, and then &lt;br /&gt;add the offset value. &lt;br /&gt;&lt;br /&gt;Logical    Logical    Physical &lt;br /&gt;segment    offset     address &lt;br /&gt;address    address &lt;br /&gt;  0001       1030     01040 &lt;br /&gt;  0002       1020     01040 &lt;br /&gt;  0003       1010     01040 &lt;br /&gt;  0004       1000     01040 &lt;br /&gt;  0005       00F0     01040 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;etc. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Five different pointer representations, all pointing to the same physical &lt;br /&gt;object. All must compare equal when compared with ==. The implementation &lt;br /&gt;is responsible for making this work. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;kenny mccomarck&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A nitpick surely worthy of this group... &lt;br /&gt;&lt;br /&gt;It's not "MS-DOS's 20-bit pointers".This is a feature of the 8086 processors (and its descendants, running in "real mode").  It is not a function of the OS in any way. &lt;br /&gt;&lt;br /&gt;Further note that the descendants still maintain this functionality; it is just that it is rarely used.  It is no longer necessary (at least up to the 4G mark.  I'm not sure what happens if you have a machine with more than 4G RAM). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;kenny mccomarck&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;And note that a *real* first-class nitpicker would point out that it's not even *MS*-DOS, as if this functionality were someone unique to and/or invented by Microsoft... &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;nick keighley&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;sophia wrote&lt;br /&gt;&gt;i am not getting your point, &lt;br /&gt;&gt;  same object with different representations ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;not possible on a sane architecture, but see the "Segmentation" section of http://en.wikipedia.org/wiki/Intel_8086 &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Morris dovey&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There are cases where it actually is sane. Consider a uP with 16-bit addressing, but where all of the memory actually available can be accessed using only the low-order 12 bits - this means that, in a "sane" design, the high-order four address bits are &lt;br /&gt;"don't cares", and that for every real location in memory, there are _sixteen_ valid addresses.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8005563524278529563?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8005563524278529563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8005563524278529563' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8005563524278529563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8005563524278529563'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/pointer-normalization.html' title='pointer normalization'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2881285876562643161</id><published>2008-04-16T04:57:00.000-07:00</published><updated>2008-04-16T05:01:10.357-07:00</updated><title type='text'>linear search Vs Binary search</title><content type='html'>In which all situations linear search will be more efficient than binary search ? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;jongware&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Unsorted data. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Harter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I assume that the data is sorted; if it is not the question is moot.  Your question really doesn't have an answer until you specify what is meant by "more efficient".  How are you measuring efficiency? &lt;br /&gt;&lt;br /&gt;A further issue is that performance is variable,depending on the item being searched.&lt;br /&gt;&lt;br /&gt;That said, in terms of wall clock time, linear search will run faster than binary search on average for N &lt; C where N is the data set size and C is an implementation specific constant that depends upon the costs of various operations.  A critical factor is whether you can place a sentinel in the data.  If you can the value of C approximately doubles.  Here are some typical values for C:&lt;br /&gt;&lt;br /&gt;    C = 12, if sentinels are not permitted&lt;br /&gt;    C = 25, if sentinels are permitted.&lt;br /&gt;    C = 50, if sentinels are permitted and do one bisection&lt;br /&gt;&lt;br /&gt;Incidentally, what you do in a sentinel based search is to place the value you are searching for at the end of the array you are searching.  By doing this you eliminate the need to check for having exhausted the array since you are guaranteed to find the item.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2881285876562643161?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2881285876562643161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2881285876562643161' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2881285876562643161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2881285876562643161'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/linear-search-vs-binary-search.html' title='linear search Vs Binary search'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-877191168477893213</id><published>2008-04-15T20:25:00.000-07:00</published><updated>2008-04-16T22:06:02.286-07:00</updated><title type='text'>String -- Anagrams</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The following is the program which i have done to find all the&lt;br /&gt;combination of letters in the string "hello"&lt;br /&gt;&lt;br /&gt; #include &lt; stdio.h &gt;&lt;br /&gt; #include &lt; stdlib.h &gt;&lt;br /&gt; #include &lt; string.h &gt;&lt;br /&gt;&lt;br /&gt; #define MAX 6&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;   char t[MAX];&lt;br /&gt;   int  i,j,k,l,m,n=1;&lt;br /&gt;&lt;br /&gt;   strcpy(t,"hello");&lt;br /&gt;&lt;br /&gt;   printf("\n words formed from the combinations of all characters from \&lt;br /&gt;   the  word hello\n\n");&lt;br /&gt;&lt;br /&gt;   for(i = 0 ;i &lt; MAX ;i++)&lt;br /&gt;   for(j = 0 ;j &lt; MAX ;j++)&lt;br /&gt;   {&lt;br /&gt;      if(j == i)&lt;br /&gt;      continue;&lt;br /&gt;&lt;br /&gt;          for(k = 0 ;k &lt; MAX ;k++)&lt;br /&gt;          {&lt;br /&gt;            if( (k==i) || (k == j) )&lt;br /&gt;            continue;&lt;br /&gt;&lt;br /&gt;            for(l = 0 ;l &lt; MAX ;l++)&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                  if( (l==i) || (l == j) || (l == k) )&lt;br /&gt;          continue;&lt;br /&gt;&lt;br /&gt;          m = 10 - (i + j + k + l);&lt;br /&gt;          printf("%c%c%c%c%c ",t[i],t[j],t[k],t[l],t[m]);&lt;br /&gt;&lt;br /&gt;                  if(n %10 == 0) puts("");&lt;br /&gt;          n++;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;          }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   printf("\n no: of words formed = %d",--n);&lt;br /&gt;&lt;br /&gt;   puts("");&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;can any one suggest a more general method so that i can find the combination of letters of any inputted string ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For a start think about moving it all to another "non main" function where you call it with the string you are interested in checking. This "MAX" everywhere is horrible. Instead in your new function&lt;br /&gt;&lt;br /&gt;displayAnagrams(char *s){&lt;br /&gt;          int len = strlen(s); /* or size_t ...... */&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Bartc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The following code (showpermutations()) displays all permutations of the&lt;br /&gt;characters in any string.&lt;br /&gt;&lt;br /&gt;But: it does not deal with repeated characters (so perms of aaa would be&lt;br /&gt;aaa,aaa,aaa,aaa,aaa,aaa). And capturing the output is tricky; here it justs&lt;br /&gt;prints the results. And, I suspect there's a much more elegant way to do&lt;br /&gt;this..&lt;br /&gt;&lt;br /&gt;I've built-in a maximum word length of 99 characters; however such a word&lt;br /&gt;would print 99! lines of output.&lt;br /&gt;&lt;br /&gt;Maybe this helps.&lt;br /&gt;&lt;br /&gt;/* Display all permutations of characters in a word. Ignores duplicate chars&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;#include &lt; stdio.h &gt;&lt;br /&gt;#include &lt; string.h &gt;&lt;br /&gt;&lt;br /&gt;void showpermutations(char *prefix, char *word);&lt;br /&gt;&lt;br /&gt;#define maxwordlen 100&lt;br /&gt;&lt;br /&gt;int main(void) {&lt;br /&gt;showpermutations("","abcd");&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void showpermutations(char *prefix, char *word) {&lt;br /&gt;char newprefix[maxwordlen];&lt;br /&gt;char newword[maxwordlen];&lt;br /&gt;char c[2]={0,0};&lt;br /&gt;char d[2]={0,0};&lt;br /&gt;int i,j,len;&lt;br /&gt;&lt;br /&gt;if (prefix==NULL || word==NULL) return;&lt;br /&gt;&lt;br /&gt;len=strlen(word);&lt;br /&gt;&lt;br /&gt;if (len&lt;=1) {&lt;br /&gt;   printf("%s%s\n",prefix,word);&lt;br /&gt;   return;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;for(i=0; i &lt; len; ++i) {&lt;br /&gt;   c[0]=word[i];&lt;br /&gt;   newword[0]=0;&lt;br /&gt;&lt;br /&gt;   for (j=0; j &lt; len; ++j)&lt;br /&gt;      if (j!=i) {&lt;br /&gt;         d[0]=word[j];&lt;br /&gt;         strcat(newword,d);&lt;br /&gt;      };&lt;br /&gt;&lt;br /&gt;   strcpy(newprefix,prefix);&lt;br /&gt;   strcat(newprefix,c);&lt;br /&gt;   showpermutations(newprefix,newword);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Willem&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To print all permutations of a string, you have to print each of its characters as a first character, and then print all the permutations of the remaining characters.&lt;br /&gt;&lt;br /&gt;One way to get 'each of the characters' and 'the remaining characters' is to rotate the string in-place so that each character is put at the front in turn.&lt;br /&gt;&lt;br /&gt;Given this, here's a recursive solution:&lt;br /&gt;&lt;br /&gt; void rotate(char *ptr, int len)&lt;br /&gt; {&lt;br /&gt;   char tmp = *ptr;&lt;br /&gt;   memmove(ptr, ptr+1, len-1);&lt;br /&gt;   ptr[len-1] = tmp;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void recurse_perms(char *str, char *ptr, int len)&lt;br /&gt; {&lt;br /&gt;   int i;&lt;br /&gt;   if (len) {&lt;br /&gt;     for (i = 0; i &lt; len; i++) {&lt;br /&gt;       recurse_perms(str, ptr+1, len-1);&lt;br /&gt;       rotate(ptr, len);&lt;br /&gt;     }&lt;br /&gt;   } else {&lt;br /&gt;     printf("%s\n", str);&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void print_perms(char *str)&lt;br /&gt; {&lt;br /&gt;   /* NB: If str can be const, make a copy here */&lt;br /&gt;   recurse_perms(str, str, strlen(str));&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;If you want more performance, you can also use a swap operation instead of a rotate, but then it's a bit harder to figure out exactly what to swap to where.&lt;br /&gt;&lt;br /&gt;Note that the recursive function returns the substring at *ptr to its original state.  This is needed for the function to work. (And that's why swapping is a lot harder conceptually.) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;user923005&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is a modification of an IOCCC entry:&lt;br /&gt;&lt;br /&gt;E:\dict&gt;foo.bat hellosophia&lt;br /&gt;&lt;br /&gt;E:\dict&gt;anagram -1 hellosophia  0&lt;big.dict 1&gt;hellosophia&lt;br /&gt;&lt;br /&gt;E:\dict&gt;anagram -2 hellosophia  0&lt;big.dict 1&gt;&gt;hellosophia&lt;br /&gt;&lt;br /&gt;E:\dict&gt;anagram -3 hellosophia  0&lt;big.dict 1&gt;&gt;hellosophia&lt;br /&gt;&lt;br /&gt;E:\dict&gt;anagram -4 hellosophia  0&lt;big.dict 1&gt;&gt;hellosophia&lt;br /&gt;E:\dict&gt;type foo.bat&lt;br /&gt;anagram -1 %1 &lt; big.dict &gt; %1&lt;br /&gt;anagram -2 %1 &lt; big.dict &gt;&gt;%1&lt;br /&gt;anagram -3 %1 &lt; big.dict &gt;&gt;%1&lt;br /&gt;anagram -4 %1 &lt; big.dict &gt;&gt;%1&lt;br /&gt;&lt;br /&gt;E:\dict&gt;type anagram.c&lt;br /&gt;&lt;br /&gt;#include &lt; stdio.h &gt;&lt;br /&gt;#include &lt; stdlib.h &gt;&lt;br /&gt;#include &lt; io.h &gt;&lt;br /&gt;#include &lt; string.h &gt;&lt;br /&gt;&lt;br /&gt;char           *getsafe(char *buffer, int count)&lt;br /&gt;{&lt;br /&gt;    char           *result = buffer,&lt;br /&gt;                   *np;&lt;br /&gt;    if ((buffer == NULL) || (count &lt; 1))&lt;br /&gt;        result = NULL;&lt;br /&gt;    else if (count == 1)&lt;br /&gt;        *result = '\0';&lt;br /&gt;    else if ((result = fgets(buffer, count, stdin)) != NULL)&lt;br /&gt;        if (np = strchr(buffer, '\n'))&lt;br /&gt;            *np = '\0';&lt;br /&gt;    return result;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static long     a[4],&lt;br /&gt;                b[4],&lt;br /&gt;                c[4],&lt;br /&gt;                d[0400],&lt;br /&gt;                e = 1;&lt;br /&gt;&lt;br /&gt;typedef struct f {&lt;br /&gt;    long            g,&lt;br /&gt;                    h,&lt;br /&gt;                    i[4],&lt;br /&gt;                    j;&lt;br /&gt;    struct f       *k;&lt;br /&gt;&lt;br /&gt;}   f;&lt;br /&gt;&lt;br /&gt;extern long     n(long *o, long *p, long *q);&lt;br /&gt;extern void     t(int i, long *p);&lt;br /&gt;extern int      u(struct f * j);&lt;br /&gt;extern int      v(struct f * j, int s);&lt;br /&gt;extern int      w(struct f * o, int r, struct f * j, int x, long p);&lt;br /&gt;extern int      y(void);&lt;br /&gt;extern int      main(int o, char **p);&lt;br /&gt;&lt;br /&gt;static f        g,&lt;br /&gt;               *l[4096];&lt;br /&gt;&lt;br /&gt;static char     h[256],&lt;br /&gt;               *m,&lt;br /&gt;                k = 3;&lt;br /&gt;&lt;br /&gt;long            n(long *o, long *p, long *q)&lt;br /&gt;{&lt;br /&gt;    long            r = 4,&lt;br /&gt;                    s,&lt;br /&gt;                    i = 0;&lt;br /&gt;    for (; r--; s = i ^ *o ^ *p, i = i &amp; *p | (i | *p) &amp; ~*o++, *q++ =&lt;br /&gt;s, p++);&lt;br /&gt;    return i;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void            t(int i, long *p)&lt;br /&gt;{&lt;br /&gt;    *c = d[i], n(a, c, b), n(p, b, p);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int             u(struct f * j)&lt;br /&gt;{&lt;br /&gt;    j-&gt;h = (j-&gt;g = j-&gt;i[0] | j-&gt;i[1] | j-&gt;i[2] | j-&gt;i[3]) &amp; 4095;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int             v(struct f * j, int s)&lt;br /&gt;{&lt;br /&gt;    int             i;&lt;br /&gt;    for (j-&gt;k-&gt;k &amp;&amp; v(j-&gt;k, ' '), fseek(stdin, j-&gt;j, 0); i =&lt;br /&gt;getchar(), putchar(i - '\n' ? i : s), i - '\n';);&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int             w(struct f * o, int r, struct f * j, int x, long p)&lt;br /&gt;{&lt;br /&gt;    f               q;&lt;br /&gt;    int&lt;br /&gt;                    s,&lt;br /&gt;                    i = o-&gt;h;&lt;br /&gt;    q.k = o;&lt;br /&gt;    r &gt; i ? j = l[r = i] : r &lt; i &amp;&amp; (s = r &amp; ~i) ? (s |= s &gt;&gt; 1, s |=&lt;br /&gt;s &gt;&gt; 2, s |= s &gt;&gt; 4, s |= s &gt;&gt; 8, j = l[r = ((r &amp; i | s) &amp; ~(s &gt;&gt; 1))&lt;br /&gt;- 1 &amp; i]) : 0;&lt;br /&gt;    --x;&lt;br /&gt;    for (; x &amp;&amp; !(p &amp; i); p &gt;&gt;= 1);&lt;br /&gt;    for (; !x &amp;&amp; j; n(o-&gt;i, j-&gt;i, q.i), u(&amp;q), q.g || (q.j = j-&gt;j,&lt;br /&gt;v(&amp;q, '\n')), j = j-&gt;k);&lt;br /&gt;    for (; x; j = x ? j-&gt;k : 0) {&lt;br /&gt;        for (; !j &amp;&amp; ((r = (r &amp; i) - 1 &amp; i) - i &amp;&amp; (r &amp; p) ? 2 : (x =&lt;br /&gt;0)); j = l[r]);&lt;br /&gt;        !x || (j-&gt;g &amp; ~o-&gt;g) || n(o-&gt;i, j-&gt;i, q.i) || (u(&amp;q), q.j = j-&lt;br /&gt;&gt;j, q.g ? w(&amp;q, r, j-&gt;k, x, p) : v(&amp;q, '\n'));&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int             y(void)&lt;br /&gt;{&lt;br /&gt;    f&lt;br /&gt;    j;&lt;br /&gt;    char           *z,&lt;br /&gt;                   *p;&lt;br /&gt;    for (; m ? j.j = ftell(stdin), 7, (m = getsafe(m, sizeof h)) ||&lt;br /&gt;w(&amp;g, 315 * 13, l[4095], k, 64 * 64) &amp; 0 : 0; n(g.i, j.i, b) ||&lt;br /&gt;(u(&amp;j), j.k = l[j.h], l[j.h] = &amp;j, y())) {&lt;br /&gt;        for (z = p = h; *z &amp;&amp; (d[*z++] || (p = 0)););&lt;br /&gt;        for (z = p ? n(j.i, j.i, j.i) + h : ""; *z; t(*z++, j.i));&lt;br /&gt;    }&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int             main(int o, char **p)&lt;br /&gt;{&lt;br /&gt;    for (; m = *++p;)&lt;br /&gt;        for (; *m - '-' ? *m : (k = -atoi(m)) &amp; 0; d[*m] || (d[*m] =&lt;br /&gt;e, e &lt;&lt;= 1), t(*m++, g.i));&lt;br /&gt;    u(&amp;g), m = h, y();&lt;br /&gt;    return 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt; E:\dict&gt;type anagram.c&lt;br /&gt;&gt; #include &lt;stdio.h&gt;&lt;br /&gt;&gt; #include &lt;stdlib.h&gt;&lt;br /&gt;&gt; #include &lt;io.h&gt;&lt;br /&gt;&lt;br /&gt;but &lt;io.h&gt; is a non standard , non ANSI header file is n't it ?&lt;br /&gt;&lt;br /&gt;E:\dict&gt;type hellosophia|more&lt;br /&gt;&lt;br /&gt; I think this should be rather E:\dict&gt;anagram hellosophia|more&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Bartc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It also generates anagrams of course rather than just all the combinations of the letters.It could also have done with small.dict rather than big.dict. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CBFalconer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This generates full anagrams.&lt;br /&gt;&lt;br /&gt;#include &lt; stdio.h &gt;&lt;br /&gt;#include &lt; string.h &gt;&lt;br /&gt;#include &lt; stdlib.h &gt;&lt;br /&gt;&lt;br /&gt;/* Public domain, by C.B. Falconer. *//* 2003-Aug-21 */&lt;br /&gt;/* Attribution appreciated. */&lt;br /&gt;&lt;br /&gt;/* Things can get out of hand when larger than 8 */&lt;br /&gt;#define MAXWORD 17&lt;br /&gt;&lt;br /&gt;/* ------------------ */&lt;br /&gt;&lt;br /&gt;/* exchange 0th and ith char in wd */&lt;br /&gt;void trade(char *wd, unsigned int i)&lt;br /&gt;{&lt;br /&gt;   char c;&lt;br /&gt;&lt;br /&gt;   c = *wd;&lt;br /&gt;   *wd = wd[i];&lt;br /&gt;   wd[i] = c;&lt;br /&gt;&lt;br /&gt;} /* trade */&lt;br /&gt;&lt;br /&gt;/* ------------------ */&lt;br /&gt;&lt;br /&gt;/* Form all n char permutations of the characters in the&lt;br /&gt;   string wd of length lgh into outstring at index ix.&lt;br /&gt;   Output the results to stdout. */&lt;br /&gt;void jumble(char *wd, unsigned int lgh,&lt;br /&gt;            unsigned int ix, /* output place to fill */&lt;br /&gt;            unsigned int n,  /* max out places to fill */&lt;br /&gt;            char        *outstring)&lt;br /&gt;{&lt;br /&gt;   unsigned int i;&lt;br /&gt;&lt;br /&gt;   if (0 == n) {&lt;br /&gt;      outstring[ix] = '\0';&lt;br /&gt;      puts(outstring);&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;      for (i = 0; i &lt; lgh; i++) {&lt;br /&gt;         trade(wd, i);     /* nop when (0 == i) */&lt;br /&gt;         outstring[ix] = *wd;&lt;br /&gt;         jumble(wd+1, lgh-1, ix+1, n-1, outstring);&lt;br /&gt;         trade(wd, i);     /* restore the wd string */&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;} /* jumble */&lt;br /&gt;&lt;br /&gt;/* ------------------ */&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[])&lt;br /&gt;{&lt;br /&gt;   unsigned int n, lgh, min;&lt;br /&gt;   double       max;&lt;br /&gt;   char         outstring[MAXWORD];&lt;br /&gt;&lt;br /&gt;   if (argc &lt; 2) {&lt;br /&gt;      fprintf(stderr,&lt;br /&gt;              "Usage: jumble &lt;baseword&gt; [lgh]\n"&lt;br /&gt;              "       where the (optional) lgh specifies the\n"&lt;br /&gt;              "       maximum length of the output words\n");&lt;br /&gt;      return 0;&lt;br /&gt;   }&lt;br /&gt;   lgh = strlen(argv[1]);&lt;br /&gt;   if (lgh &gt;= MAXWORD) argv[1][lgh = MAXWORD-1] = '\0';&lt;br /&gt;&lt;br /&gt;   min = lgh;&lt;br /&gt;   if ((argc &gt; 2) &amp;&amp; (1 == sscanf(argv[2], "%u", &amp;n)))&lt;br /&gt;      if (n &amp;&amp; (n &lt;= lgh)) min = n;&lt;br /&gt;&lt;br /&gt;   for (n = lgh, max = 1.0; n &gt; (lgh - min); n--)&lt;br /&gt;      max = max * n;&lt;br /&gt;&lt;br /&gt;   fprintf(stderr, "string=\"%s\", max=%.0f, len=%u\n",&lt;br /&gt;                    argv[1], max, min);&lt;br /&gt;&lt;br /&gt;   jumble(argv[1], lgh, 0, min, outstring);&lt;br /&gt;   return 0;&lt;br /&gt;&lt;br /&gt;} /* main */&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-877191168477893213?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/877191168477893213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=877191168477893213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/877191168477893213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/877191168477893213'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/string-anagrams.html' title='String -- Anagrams'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-871626903725073107</id><published>2008-04-15T20:14:00.000-07:00</published><updated>2008-04-16T21:54:14.672-07:00</updated><title type='text'>y &gt;&gt; (8 * (sizeof(int) -1))</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Is  y &gt;&gt; (8 * (sizeof(int) -1)) portable expression to find The MSB of an unsigned integer y ??&lt;br /&gt;will this work in all the cases, all three of the representations C allows:&lt;br /&gt;&lt;br /&gt;1) two's complement  2) ones'complement  3) signed magnitude.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;joachim schmitz&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Probably better and more portable:&lt;br /&gt;#include &lt;limits.h&gt;&lt;br /&gt;...&lt;br /&gt;y &gt;&gt; (CHAR_BIT * (sizeof y -1)) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Harald van Dijk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No, it isn't. &lt;br /&gt;&lt;br /&gt;&gt;  1) two's complement&lt;br /&gt;&gt;  2) ones'complement&lt;br /&gt;&gt;  3) signed magnitude.&lt;br /&gt;&lt;br /&gt;These differ in how negative values are represented. Why do you think negative values matter, given that you've got an unsigned integer? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Peter Nilsson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Define MSB in the following case...&lt;br /&gt;&lt;br /&gt;  CHAR_BIT = 8&lt;br /&gt;  UINT_MAX = 262143&lt;br /&gt;&lt;br /&gt;If you want the top CHAR_BIT bits from an unsigned int y, use...&lt;br /&gt;&lt;br /&gt;  y / ((UINT_MAX &gt;&gt; (CHAR_BIT - 1) &gt;&gt; 1) + 1)&lt;br /&gt;&lt;br /&gt;&gt; will this work in all the cases, all three of the representations C&lt;br /&gt;&gt; allows:&lt;br /&gt;&lt;br /&gt;&gt;  1) two's complement&lt;br /&gt;&gt;  2) ones'complement&lt;br /&gt;&gt;  3) signed magnitude.&lt;br /&gt;&lt;br /&gt;Unsigned integers use pure binary representation. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Jack klein&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt; Is  y &gt;&gt; (8 * (sizeof(int) -1)) portable expression to find The MSB of&lt;br /&gt;&gt; an unsigned integer y ??&lt;br /&gt;&lt;br /&gt;It is absolutely not portable, even if you change 8 to CHAR_BIT.&lt;br /&gt;&lt;br /&gt;I do a lot of work on a DSP where sizeof(char), sizeof(short), and sizeof(int) are all 1.  CHAR_BIT happens to be 16, of course, and sizeof(long) is 2, sizeof(long long) is 4.&lt;br /&gt;So on this implementation, either of the expressions:&lt;br /&gt;&lt;br /&gt;   (8 * (1 - 1))&lt;br /&gt;&lt;br /&gt;...or:&lt;br /&gt;&lt;br /&gt;   (16 * (1 - 1))&lt;br /&gt;&lt;br /&gt;...will not tell you anything about the MSB.&lt;br /&gt;&lt;br /&gt;&gt; will this work in all the cases, all three of the representations C&lt;br /&gt;&gt; allows:&lt;br /&gt;&lt;br /&gt;&gt;  1) two's complement&lt;br /&gt;&gt;  2) ones'complement&lt;br /&gt;&gt;  3) signed magnitude.&lt;br /&gt;&lt;br /&gt;As others have stated, the representation of the signed int types in a C implementation has nothing to do with the unsigned types.&lt;br /&gt;&lt;br /&gt;Try this:&lt;br /&gt;&lt;br /&gt;#include &lt; limits.h &gt;&lt;br /&gt;&lt;br /&gt;#define UINT_MSB_MASK   (UINT_MAX - (UINT_MAX &gt;&gt; 1))&lt;br /&gt;&lt;br /&gt;if (some_unsigned_int &amp; UINT_MSB_MASK)&lt;br /&gt;   /* do stuff because it is set */&lt;br /&gt;else&lt;br /&gt;   /* do stuff because it is not set */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;harald van dijk wrote&lt;br /&gt;&lt;br /&gt;&gt; These differ in how negative values are represented. Why do &gt;you think negative values matter, given that you've got an &gt;unsigned integer?&lt;br /&gt;&lt;br /&gt;what about finding the MSB of a signed integer ? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Flash gordon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You cannot find that by shifting since right shifting a negative value gives an implementation defined result and left shifting a 1 in to the MSB invokes undefined behaviour. If you want to know the sign and don't care about negative zero then just use either &lt;0 or &gt;=0 as appropriate&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-871626903725073107?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/871626903725073107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=871626903725073107' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/871626903725073107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/871626903725073107'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/y-8-sizeofint-1.html' title='y &gt;&gt; (8 * (sizeof(int) -1))'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8922982753692341333</id><published>2008-04-15T20:08:00.000-07:00</published><updated>2008-04-16T04:21:14.154-07:00</updated><title type='text'>printf("....%d",sizeof((int)(double)(char) i))</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;why printf("....%d",sizeof((int)(double)(char) i)) always gives the size of int ???&lt;br /&gt;is it because sizeof doesn't evaluate its operand....???&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Peter Nilsson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;is it because sizeof doesn't evaluate its operand....???&lt;br /&gt;&lt;br /&gt;With the exception of variable length arrays in C99, yes.&lt;br /&gt;&lt;br /&gt;The object i doesn't even have to be initialised. Even the following is valid...&lt;br /&gt;&lt;br /&gt;  sizeof( (int) (int (*)(void)) -1 )&lt;br /&gt;&lt;br /&gt;...even though there is no well defined conversion involved at any stage. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Joachim schmitz&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is because your code is just the longer version of printf("....%d",sizeof(int))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ivar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By doing printf("....%d",sizeof((int)(double)(char) i)), you're finally casting i to an int, so it would print the sizeof(int) value.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8922982753692341333?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8922982753692341333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8922982753692341333' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8922982753692341333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8922982753692341333'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/printfdsizeofintdoublechar-i.html' title='printf(&quot;....%d&quot;,sizeof((int)(double)(char) i))'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8597211314343449799</id><published>2008-04-15T19:59:00.000-07:00</published><updated>2008-04-15T20:02:26.534-07:00</updated><title type='text'>nodes in a linked list</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Is there any condition / requirement that nodes in linked list must be stored in contigous memory locations ? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;gw7rib&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Far from it. Some of the main advantages of a linked list are that you can delete nodes in the middle of a list without having to move anything, add new nodes at the end, add extra nodes in the middle (again without moving anything), and change the order of the nodes without actually moving them. This would not be possible if the nodes had to be stored in contiguous locations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8597211314343449799?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8597211314343449799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8597211314343449799' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8597211314343449799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8597211314343449799'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/nodes-in-linked-list.html' title='nodes in a linked list'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6531409120026462609</id><published>2008-04-15T07:49:00.001-07:00</published><updated>2008-04-15T07:51:39.634-07:00</updated><title type='text'>Node deletion in binary tree</title><content type='html'>&lt;a href="http://1.bp.blogspot.com/_hNduP9F5jm4/SATA6k2wZrI/AAAAAAAAACY/iXx_8CxMbzI/s1600-h/Picture7.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_hNduP9F5jm4/SATA6k2wZrI/AAAAAAAAACY/iXx_8CxMbzI/s320/Picture7.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5189484783195940530" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_hNduP9F5jm4/SATAv02wZqI/AAAAAAAAACQ/88QXuZUvmUw/s1600-h/Picture8.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_hNduP9F5jm4/SATAv02wZqI/AAAAAAAAACQ/88QXuZUvmUw/s320/Picture8.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5189484598512346786" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_hNduP9F5jm4/SATAl02wZpI/AAAAAAAAACI/bDhLDsWtSec/s1600-h/Picture9.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_hNduP9F5jm4/SATAl02wZpI/AAAAAAAAACI/bDhLDsWtSec/s320/Picture9.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5189484426713654930" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6531409120026462609?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6531409120026462609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6531409120026462609' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6531409120026462609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6531409120026462609'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/node-deletion-in-binary-tree.html' title='Node deletion in binary tree'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_hNduP9F5jm4/SATA6k2wZrI/AAAAAAAAACY/iXx_8CxMbzI/s72-c/Picture7.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1591560513173737242</id><published>2008-04-14T13:16:00.000-07:00</published><updated>2008-12-25T07:21:49.809-08:00</updated><title type='text'>Complete Binary Tree</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SVOk_-H5v4I/AAAAAAAAAzg/Xuesx8eh23U/s1600-h/Screenshot2.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SVOk_-H5v4I/AAAAAAAAAzg/Xuesx8eh23U/s320/Screenshot2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5283748206750580610" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1591560513173737242?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1591560513173737242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1591560513173737242' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1591560513173737242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1591560513173737242'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/url-vs-uri.html' title='Complete Binary Tree'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/SVOk_-H5v4I/AAAAAAAAAzg/Xuesx8eh23U/s72-c/Screenshot2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2676796750166621548</id><published>2008-04-14T06:54:00.000-07:00</published><updated>2008-04-14T06:57:06.267-07:00</updated><title type='text'>catalan numbers</title><content type='html'>&lt;strong&gt;Catalan numbers&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;for n &gt;= 0, the nth catalan number is given as &lt;br /&gt;&lt;br /&gt;cat(n) = C(2n,n)/(n+1) =&gt; (2n)!/(n+1)!n!&lt;br /&gt;&lt;br /&gt;The no: of  distinct binary trees with n vertices, n &gt;= 0 , is the nth catalan number cat(n) &lt;br /&gt;                                                             &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;see:- http://en.wikipedia.org/wiki/Catalan_numbers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2676796750166621548?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2676796750166621548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2676796750166621548' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2676796750166621548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2676796750166621548'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/catalan-numbers.html' title='catalan numbers'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7146523463360927099</id><published>2008-04-14T06:33:00.000-07:00</published><updated>2008-04-14T06:36:11.212-07:00</updated><title type='text'>Heap creation</title><content type='html'>program which shows the creation of heap from  an array of elements &lt;br /&gt;&lt;br /&gt; #include &lt; stdio.h &gt;&lt;br /&gt; #include &lt; stdlib.h &gt;&lt;br /&gt; #define MAX 50&lt;br /&gt;&lt;br /&gt; void restoreup(int,int*);&lt;br /&gt; void restoredown(int,int*,int);&lt;br /&gt; void makeheap(int*,int);&lt;br /&gt; void add(int,int*,int*);&lt;br /&gt; void display(int*,int);&lt;br /&gt;  int readval(void);&lt;br /&gt;  int del(int*,int*);&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;   int a[MAX] = {1000,7,10,25,17,23};&lt;br /&gt;   int n = 5,i;&lt;br /&gt;&lt;br /&gt;   makeheap(a,n);&lt;br /&gt;   display(a,n);&lt;br /&gt;&lt;br /&gt;   printf("\n\nEnter the element you want to add:: ");&lt;br /&gt;   i= readval();&lt;br /&gt;   add(i,a,&amp;n);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   printf("\nAfter adding the element %d\n",i);&lt;br /&gt;   display(a,n);&lt;br /&gt;&lt;br /&gt;   i = del(a,&amp;n);&lt;br /&gt;   printf("\n\nAfter Deletion\n");&lt;br /&gt;   display(a,n);&lt;br /&gt;&lt;br /&gt;   puts("");&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void makeheap(int *a,int n)&lt;br /&gt; {&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   for(i= (n/2);i&gt;= 1;i--)&lt;br /&gt;   restoredown(i,a,n);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void restoredown(int pos,int *a,int n)&lt;br /&gt; {&lt;br /&gt;   int i,val;&lt;br /&gt;   val = a[pos];&lt;br /&gt;&lt;br /&gt;   while(pos &lt;= n/2)&lt;br /&gt;   {&lt;br /&gt;     i = 2 * pos;&lt;br /&gt;&lt;br /&gt;     if((i &lt; n) &amp;&amp; (a[i] &lt; a[i+1]))&lt;br /&gt;     i++;&lt;br /&gt;&lt;br /&gt;     if(val &gt;= a[i])&lt;br /&gt;     break;&lt;br /&gt;&lt;br /&gt;     a[pos] = a[i];&lt;br /&gt;     pos  = i;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;    a[pos] = val;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  int readval()&lt;br /&gt;  {&lt;br /&gt;    int i,ch;&lt;br /&gt;&lt;br /&gt;    while( (1 != scanf("%d",&amp;i)) )&lt;br /&gt;    {&lt;br /&gt;      while( (ch= fgetc(stdin)) != EOF &amp;&amp; ch != '\n');&lt;br /&gt;      printf("\nSorry i could n't read that\nplease re enter the value:: ");&lt;br /&gt;&lt;br /&gt;      if(1 == scanf("%d",&amp;i))&lt;br /&gt;      break;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;    return i;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  void display(int *a,int n)&lt;br /&gt;  {&lt;br /&gt;    int i;&lt;br /&gt;&lt;br /&gt;    printf("\n**********");&lt;br /&gt;    printf("\n    HEAP  ");&lt;br /&gt;    printf("\n**********\n");&lt;br /&gt;&lt;br /&gt;    puts("");&lt;br /&gt;    for(i=1;i &lt;= n;i++)&lt;br /&gt;    printf("%d\t",a[i]);&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  void add(int val,int* a,int* n)&lt;br /&gt;  {&lt;br /&gt;    (*n)++;&lt;br /&gt;    a[*n] = val;&lt;br /&gt;    restoreup(*n,a);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  void restoreup(int i,int *a)&lt;br /&gt;  {&lt;br /&gt;&lt;br /&gt;     int val;&lt;br /&gt;     val = a[i];&lt;br /&gt;&lt;br /&gt;    while(a[i/2] &lt;= val)&lt;br /&gt;    {&lt;br /&gt;       a[i] = a[i/2];&lt;br /&gt;       i = i/2;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    a[i] = val;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  int del(int* a , int *n)&lt;br /&gt;  {&lt;br /&gt;     int temp,i;&lt;br /&gt;&lt;br /&gt;     temp = a[1];&lt;br /&gt;     a[1] = a[*n];&lt;br /&gt;     (*n)--;&lt;br /&gt;&lt;br /&gt;     restoredown(1,a,*n);&lt;br /&gt;     return temp;&lt;br /&gt;  }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7146523463360927099?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7146523463360927099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7146523463360927099' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7146523463360927099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7146523463360927099'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/heap-creation.html' title='Heap creation'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-794360708375606243</id><published>2008-04-14T06:18:00.000-07:00</published><updated>2008-04-14T06:48:13.031-07:00</updated><title type='text'>Tree  from preorder and inorder traversals</title><content type='html'>&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_hNduP9F5jm4/SANaa02wZmI/AAAAAAAAAB0/RzZ2hRXbld8/s1600-h/Picture1.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5189090612572350050" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://1.bp.blogspot.com/_hNduP9F5jm4/SANaa02wZmI/AAAAAAAAAB0/RzZ2hRXbld8/s320/Picture1.jpg" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_hNduP9F5jm4/SANaTk2wZlI/AAAAAAAAABs/LGQI3WYUGSI/s1600-h/Picture2.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5189090488018298450" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://4.bp.blogspot.com/_hNduP9F5jm4/SANaTk2wZlI/AAAAAAAAABs/LGQI3WYUGSI/s320/Picture2.jpg" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_hNduP9F5jm4/SANaJU2wZkI/AAAAAAAAABk/lLcvIfYIycA/s1600-h/Picture3.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5189090311924639298" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_hNduP9F5jm4/SANaJU2wZkI/AAAAAAAAABk/lLcvIfYIycA/s320/Picture3.jpg" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_hNduP9F5jm4/SANaB02wZjI/AAAAAAAAABc/Vw-K4oyJKTs/s1600-h/Picture4.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5189090183075620402" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://1.bp.blogspot.com/_hNduP9F5jm4/SANaB02wZjI/AAAAAAAAABc/Vw-K4oyJKTs/s320/Picture4.jpg" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;program which shows the re-construction of a binary tree from inorder and preorder traversals &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #include &lt; stdio.h  &gt;&lt;br /&gt; #include &lt; stdlib.h &gt;&lt;br /&gt; #include &lt; string.h &gt;&lt;br /&gt; #include &lt; limits.h &gt;&lt;br /&gt;&lt;br /&gt; typedef struct node&lt;br /&gt; {&lt;br /&gt;   struct node *left;&lt;br /&gt;   int val;&lt;br /&gt;   struct node *right;&lt;br /&gt; }sn;&lt;br /&gt;&lt;br /&gt; void inordert(sn*);&lt;br /&gt; void freetree(sn*);&lt;br /&gt;&lt;br /&gt; int getcount(int*);&lt;br /&gt; int getroot(int*,int);&lt;br /&gt; int getminindex(int*,int);&lt;br /&gt; int* getleft(int,int*,int*);&lt;br /&gt; int* getright(int,int*,int*);&lt;br /&gt;&lt;br /&gt; sn* reconst(int,int*,int);&lt;br /&gt; sn* allocate(int);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int preorder[] = {'A','B','D','G','H','C','E','F','I','K','J',0};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;   int  inorder[] = {'B','G','H','D','A','E','C','I','K','F','J',0};&lt;br /&gt;   int i,arc;&lt;br /&gt;&lt;br /&gt;   sn* t=NULL;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   arc = getcount(inorder);&lt;br /&gt;&lt;br /&gt;   t= reconst(preorder[0],inorder, arc);&lt;br /&gt;&lt;br /&gt;   printf("after reconstruction of the binary tree\n");&lt;br /&gt;   inordert(t);&lt;br /&gt;&lt;br /&gt;   freetree(t);&lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; sn* reconst(int root,int *inorder,int arc)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;       int *nla,*nra,nlarc,nroot,i;&lt;br /&gt;       int nrarc;&lt;br /&gt;&lt;br /&gt;       sn* temp =NULL;&lt;br /&gt;       nlarc=nrarc=0;&lt;br /&gt;&lt;br /&gt;        if(arc == 0)&lt;br /&gt;        return NULL;&lt;br /&gt;&lt;br /&gt;        temp = allocate(root);&lt;br /&gt;&lt;br /&gt;        if(arc == 1)&lt;br /&gt;        return temp;&lt;br /&gt;&lt;br /&gt;        nla = getleft(root,inorder,&amp;nlarc);&lt;br /&gt; nroot = getroot(nla,nlarc);&lt;br /&gt; temp -&gt; left = reconst(nroot,nla,nlarc);&lt;br /&gt; free(nla);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; nra = getright(root,inorder,&amp;nrarc);&lt;br /&gt; nroot = getroot(nra,nrarc);&lt;br /&gt; temp -&gt; right = reconst(nroot,nra,nrarc);&lt;br /&gt;        free(nra);&lt;br /&gt;&lt;br /&gt;        return temp;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;  int getcount(int *inorder)&lt;br /&gt;  {&lt;br /&gt;     int count=0,i;&lt;br /&gt;     for(i=0;inorder[i] != 0;i++)&lt;br /&gt;     count++;&lt;br /&gt;&lt;br /&gt;     return count;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; sn* allocate(int n)&lt;br /&gt; {&lt;br /&gt;   sn* temp;&lt;br /&gt;   temp = malloc(sizeof(*temp));&lt;br /&gt;&lt;br /&gt;   if(!temp)&lt;br /&gt;   {&lt;br /&gt;     printf("\n memory allocation failed....");&lt;br /&gt;     printf("\n going to abort.....");&lt;br /&gt;  exit(1);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   temp -&gt; val   = n;&lt;br /&gt;   temp -&gt; left  = NULL;&lt;br /&gt;   temp -&gt; right = NULL;&lt;br /&gt;&lt;br /&gt;   return temp;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int* getleft(int root,int *inorder,int *larc)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;   int i,count;&lt;br /&gt;   int *nla;&lt;br /&gt;&lt;br /&gt;   i=0,count=0;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   while(inorder[i] != root)&lt;br /&gt;   { i++;count++;}&lt;br /&gt;&lt;br /&gt;   nla = malloc((count+1) * sizeof(*nla));&lt;br /&gt;   nla[count] =0;&lt;br /&gt;&lt;br /&gt;   for(i=0;i &lt; count;i++)&lt;br /&gt;   nla[i] = inorder[i];&lt;br /&gt;   *larc = count;&lt;br /&gt;&lt;br /&gt;   return nla;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int getroot(int *in,int n)&lt;br /&gt; {&lt;br /&gt;    int i,j=0,k;&lt;br /&gt;    int* indxarray = malloc(n * sizeof(*indxarray));&lt;br /&gt;&lt;br /&gt;    if(indxarray == NULL)&lt;br /&gt;    {&lt;br /&gt;       printf("\n memory allocation failed....");&lt;br /&gt;       exit(1);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    memset(indxarray,-1,n);&lt;br /&gt;&lt;br /&gt;    for(k=0;k &lt; n;k++)&lt;br /&gt;    {&lt;br /&gt;      i=0;&lt;br /&gt;      while(preorder[i])&lt;br /&gt;      {&lt;br /&gt;        if(preorder[i] == in[k])&lt;br /&gt; indxarray[k] = i;&lt;br /&gt; i++;&lt;br /&gt;       }&lt;br /&gt;    }&lt;br /&gt;   j = getminindex(indxarray,n);&lt;br /&gt;   return in[j];&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int getminindex(int *index,int n)&lt;br /&gt; {&lt;br /&gt;   int loc = -1;&lt;br /&gt;   int min = INT_MAX;&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   for(i=0;i &lt; n;i++)&lt;br /&gt;    {&lt;br /&gt;      if(index[i] &lt; min)&lt;br /&gt;       {&lt;br /&gt;         min = index[i];&lt;br /&gt;  loc = i;&lt;br /&gt;       }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;   return loc;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int* getright(int root,int *inorder,int *larc)&lt;br /&gt; {&lt;br /&gt;   int i,count,pos,k;&lt;br /&gt;   int *nra,ncount;&lt;br /&gt;   i=0,count=0,pos=0,ncount=0;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   while(inorder[i] != root)&lt;br /&gt;   { i++;pos++;}&lt;br /&gt;&lt;br /&gt;   count = getcount(inorder);&lt;br /&gt;   ncount = (count-pos-1);&lt;br /&gt;&lt;br /&gt;   nra = malloc( (ncount+1) * sizeof(*nra));&lt;br /&gt;   nra[ncount] =0;&lt;br /&gt;   k = (pos+1);&lt;br /&gt;&lt;br /&gt;   for(i=0;i &lt; ncount;i++)&lt;br /&gt;   {&lt;br /&gt;     nra[i] = inorder[k];&lt;br /&gt;     k++;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   *larc = ncount;&lt;br /&gt;    return nra;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void inordert(sn *hd)&lt;br /&gt; {&lt;br /&gt;    if(hd != NULL)&lt;br /&gt;    {&lt;br /&gt;       inordert(hd -&gt; left);&lt;br /&gt;       printf("\t %c",hd -&gt; val);&lt;br /&gt;       inordert(hd -&gt; right);&lt;br /&gt;    }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void freetree(sn* hd)&lt;br /&gt; {&lt;br /&gt;   if(hd)&lt;br /&gt;   {&lt;br /&gt;     freetree(hd -&gt; left);&lt;br /&gt;     freetree(hd -&gt; right);&lt;br /&gt;   }&lt;br /&gt;   free(hd);&lt;br /&gt; }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-794360708375606243?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/794360708375606243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=794360708375606243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/794360708375606243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/794360708375606243'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/tree-from-preorder-and-inorder.html' title='Tree  from preorder and inorder traversals'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_hNduP9F5jm4/SANaa02wZmI/AAAAAAAAAB0/RzZ2hRXbld8/s72-c/Picture1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2370410192993860151</id><published>2008-04-10T20:53:00.000-07:00</published><updated>2008-04-14T07:21:07.240-07:00</updated><title type='text'>scanf(" \"%[^\"]\"",s)</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sulekha&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;scanf(" \"%[^\"]\"",s);  means&lt;br /&gt;&lt;br /&gt;The scanf will expect a string enclosed within double quotes for correctly reading the input. Within the double quotes it will acceptany input other than ". It will stop reading at the second " character.&lt;br /&gt;&lt;br /&gt;is this explanation correct..??? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Almost.  In addition to what you've described, the scanf() will also read and discard white space (if any) prior to the first quote mark.&lt;br /&gt;&lt;br /&gt;STRONG recommendation: Use something like "%100[" instead of just "%[", to avoid re-inventing the hazards of gets().&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;sulekha&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;suppose if I change scanf(" \"%[^\"]\"",s); to &lt;br /&gt;&lt;br /&gt;scanf("\"%[^\"]\"",s); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;the scanf() won't read and discard white space (if any) prior to the first quote mark. isn't it ? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eric sosman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;No.  The format string now starts with " so scanf() will try to match a " at the start of the input.  Any other input character would be a mismatch, and would cause scanf() to stop (and leave the mismatched character unread). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;robert gamble&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In addition to Eric's comments, it is worth noting that the "%[" conversion specifier matches *one or more* characters so it will fail if there are no characters between the quotes, i.e. "".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2370410192993860151?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2370410192993860151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2370410192993860151' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2370410192993860151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2370410192993860151'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/scanf-s.html' title='scanf(&quot; \&quot;%[^\&quot;]\&quot;&quot;,s)'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-5772526426632624423</id><published>2008-04-10T11:36:00.000-07:00</published><updated>2009-01-12T10:52:42.761-08:00</updated><title type='text'>Evaluating arithmetic expressions</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SWuRbTp0rrI/AAAAAAAAA2c/D_1RCPM9S58/s1600-h/Screenshot4.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SWuRbTp0rrI/AAAAAAAAA2c/D_1RCPM9S58/s320/Screenshot4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5290482085594967730" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-5772526426632624423?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/5772526426632624423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=5772526426632624423' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5772526426632624423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5772526426632624423'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/mathematical-markup-language.html' title='Evaluating arithmetic expressions'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SWuRbTp0rrI/AAAAAAAAA2c/D_1RCPM9S58/s72-c/Screenshot4.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7441671435341554537</id><published>2008-04-10T10:47:00.000-07:00</published><updated>2008-04-10T10:57:20.204-07:00</updated><title type='text'>producing the memory layout you really want is non-portable and deprecated</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I used to argue at this point that using memory-mapped IO made it easier to write device drivers in C, since you could map devices to C structures. Unfortunately, modern C compilers pad structures for performance reasons, and trying to coerce the compiler into producing the memory layout you really want is non-portable and deprecated. So I'm leaving the argument in place, but it's really for historical interest at this point. The comments about trying to create in and out instructions do remain valid, however.&lt;br /&gt;&lt;br /&gt;Also, when writing device drivers in C, it's a lot easier to work with when devices are in memory space. Let's suppose you have a simple device (for concreteness, let's look at the A/D convertor on an HC11. It's controlled by five registers (not counting the OPTION register), located at addresses $1030-$1034. We can define a struct that looks like this:&lt;br /&gt;&lt;br /&gt;see:- http://www.cs.nmsu.edu/~pfeiffer/classes/473/notes/io.html &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which begs the question : since people have known for a long time that C was going to be used primarily for embedded systems in the future, why oh why is the support for non padded structures so bad? Sure some compilers have a pragma to remove padding but thats not "standard".&lt;br /&gt;&lt;br /&gt;The FAQ says this:&lt;br /&gt;&lt;br /&gt;http://c-faq.com/struct/padding.html&lt;br /&gt;&lt;br /&gt;I would be interested in seeing a general approach to this&lt;br /&gt;&lt;br /&gt;,----&lt;br /&gt;| If you're worried about wasted space, you can minimize the effects of padding by ordering the members of a structure based on their base types, from largest to smallest.&lt;br /&gt;`----&lt;br /&gt;&lt;br /&gt;that is "standards compliant" and not "hard coded". &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ian collins&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Every embedded compiler (ant that's quite a lot!) I've used supported packed structures.  I certainly would think many times about using one that didn't.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard&lt;/span&gt;&lt;br /&gt;Is the pragma line itself "standard"? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ian collins&lt;/span&gt;&lt;br /&gt;Don't be silly, how can you standardise something a lot of machinescan't do? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard&lt;/span&gt;&lt;br /&gt;It could stop the compilation? Hence standard code base. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Philip potter&lt;/span&gt;&lt;br /&gt;The same way you standardise IEEE floating point - that is, make it an optional part of the standard. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:&lt;br /&gt;&lt;br /&gt;&gt; I used to argue at this point that using memory-mapped IO made it&lt;br /&gt;&gt; easier to write device drivers in C, since you could map devices to C&lt;br /&gt;&gt; structures. Unfortunately, modern C compilers pad structures for&lt;br /&gt;&gt; performance reasons, and trying to coerce the compiler into producing&lt;br /&gt;&gt; the memory layout you really want is non-portable and deprecated.&lt;br /&gt;&gt; [...]&lt;br /&gt;&lt;br /&gt;Another problem that's frequently overlooked is that just getting the struct to match the hardware may not be enough. Quite commonly, such magical memory addresses are "sensitive" only when accessed in the right way: A word-sized register might respond only to a word-sized fetch or store, but not to partial accesses in byte units nor to doubleword accesses that touch two adjoining registers.  Careful use of volatile can enforce the proper ordering of events (e.g., write to the "data" register *before* writing to the "strobe" register), but isn't enough to prevent an aggressive optimizer from using "store immediate byte" instead of "load word to register,store word."&lt;br /&gt;&lt;br /&gt;That's part of what the Standard means when it says that what constitutes an "access" to a volatile variable is implementation-defined.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Morris dovey&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:&lt;br /&gt;&lt;br /&gt;&gt; I used to argue at this point that using memory-mapped IO made it&lt;br /&gt;&gt; easier to write device drivers in C, since you could map devices to C&lt;br /&gt;&gt; structures.&lt;br /&gt;&gt;Also, when writing device drivers in C, it's a lot easier to work&lt;br /&gt;&gt; with when devices are in memory space. Let's suppose you have a simple&lt;br /&gt;&gt; device (for concreteness, let's look at the A/D convertor on an HC11.&lt;br /&gt;&gt; It's controlled by five registers (not counting the OPTION register),&lt;br /&gt;&gt; located at addresses $1030-$1034. We can define a struct that looks&lt;br /&gt;&gt; like this:&lt;br /&gt;&lt;br /&gt;It's at least as easy to use #defines to create pointer values to do the same job. In the case of your A/D, a base address ($1030) and offsets ($0-$4) is sufficient to #define five pointer values&lt;br /&gt;to access (probably volatile) registers of whatever size needed.&lt;br /&gt;&lt;br /&gt;It's simple, it's easy, and it removes all possible concerns about structure padding and the chance that different toolchains might produce different results.&lt;br /&gt;&lt;br /&gt;... and to provide an example of this method I've posted a copy of a header file I once actually used. The register offsets for the various devices were placed in separate device-specific&lt;br /&gt;header files that included this.&lt;br /&gt;&lt;br /&gt;The file can be found at http://www.iedu.com/c/mips_io.h&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7441671435341554537?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7441671435341554537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7441671435341554537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7441671435341554537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7441671435341554537'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/producing-memory-layout-you-really-want.html' title='producing the memory layout you really want is non-portable and deprecated'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2520549307030240913</id><published>2008-04-10T04:46:00.000-07:00</published><updated>2009-08-02T09:39:53.342-07:00</updated><title type='text'>Interpositioning in C-code</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/SnXBUPOc0lI/AAAAAAAABc4/qjAhaDk5aGs/s1600-h/interpositioning1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 201px;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/SnXBUPOc0lI/AAAAAAAABc4/qjAhaDk5aGs/s320/interpositioning1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5365407084510499410" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/SnXBPJVgL7I/AAAAAAAABcw/oTYbxCjxVCA/s1600-h/interpositioning2.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 182px;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/SnXBPJVgL7I/AAAAAAAABcw/oTYbxCjxVCA/s320/interpositioning2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5365406997030121394" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2520549307030240913?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2520549307030240913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2520549307030240913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2520549307030240913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2520549307030240913'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/will-windows-work-continuously-for-more.html' title='Interpositioning in C-code'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/SnXBUPOc0lI/AAAAAAAABc4/qjAhaDk5aGs/s72-c/interpositioning1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-961146850844494266</id><published>2008-04-09T23:18:00.000-07:00</published><updated>2008-04-09T23:26:45.098-07:00</updated><title type='text'>x&amp;(x-1) ... why only 2's complement system?</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Lax&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Why is the "x&amp;(x-1)" trick for removing the least significant set bit from an integer only valid on 2's complement systems? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CBFalconner&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It works fine on unsigned integers also.  Just write down the bit patterns involved.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;walter roberson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Consider signed-magnitude and the number -2. 1 for the sign, a bunch of binary 0s, then binary 10 at the end. x-1 is -3, which is 1 for the sign, a bunch of binary 0s, then binary 11 at the end.&lt;br /&gt;Bitwise and the two together and you get 1 for the sign, a bunch of binary 0s, then binary 10 at the end. Which is the representation of -2 which is the number you started with, so the technique does not work for signed-magnitude.&lt;br /&gt;&lt;br /&gt;With this example in mind, you should easily be able to determine whether the technique works for 1's complement systems. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is valid on all systems if `x' is non-negative.That means, as a particularly useful special case, that it is always valid if `x' is unsigned.&lt;br /&gt;&lt;br /&gt;For negative values of `x', I suggest you take pencil and paper and work through a few examples, using &lt;span style="font-weight:bold;"&gt;all three of the representations C allows: two's complement, ones'complement, and signed magnitude&lt;/span&gt;.  To save some writing,pretend your computer uses a narrow int of maybe six oreight bits.  Try a few different `x' values like -1, -2,-10, and see what happens. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Lax&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So is this a good implementation-independent way of doing it?: &lt;br /&gt;(signed)( x &amp; ( (unsigned)x-1 ) ) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Peter Nilsson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No, the right way is to make x unsigned to begin with, and to forget about testing bits in negative integers. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CBFalconer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;Lax wrote&lt;br /&gt;&gt;So is this a good implementation-independent way of doing it?&lt;br /&gt;&gt; (signed)( x &amp; ( (unsigned)x-1 ) )&lt;br /&gt;&lt;br /&gt;NO.It is a good way of getting undefined behaviour.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-961146850844494266?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/961146850844494266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=961146850844494266' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/961146850844494266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/961146850844494266'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/x-why-only-2s-complement-system.html' title='x&amp;(x-1) ... why only 2&apos;s complement system?'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7380740243494852463</id><published>2008-04-09T22:37:00.000-07:00</published><updated>2008-04-09T22:39:47.536-07:00</updated><title type='text'>print output</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Is it possible to write a C program to print o/p without using library functions( in standard C )..????&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Walter roberson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On -some- implementations.&lt;br /&gt;&lt;br /&gt;There are some implementations that have memory-mapped I/O --writing a byte to a particular address causes the byte to be sent to I/O (e.g., to a serial port or to a printer or whatever.)&lt;br /&gt;&lt;br /&gt;Standard C does not -promise- that there is any way to write data to a particular absolute address, but Standard C says thatit is implementation defined as to what the meaning is of converting an integral value into a pointer. Hence an implementation is allowed to define the conversion of magic absolute I/O addresses into valid pointers to write to and thus to potentially trigger I/O.&lt;br /&gt;&lt;br /&gt;Any program that used this technique would not be portable to any other system that did not use memory-mapped I/O, or which used different addresses for memory-mapped I/O, or to any system that had memory-protection that prevented users from writing to the magic addresses -- and of course it would not be portable to any system that basically defines the result of converting an integral value to a pointer as creating a useless junk pointer.&lt;br /&gt;&lt;br /&gt;But any program that used this technique successfully for a specific system would not be violating any constraint in C.&lt;br /&gt;&lt;br /&gt;The ability to create arbitrary pointers is fairly common in C implementations -- the C standard doesn't promise it will work though. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Default user&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Why do you want to? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;walter roberson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When I gave my reply earlier, I assumed that it yet another "job interview" type question.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, 25 years ago, I had real reasons for wanting to know similar information, as I was working on a multiuser 128 Mb system with no shared libraries, and being able to omit the C library from the (static) link meant a (relatively) major reduction in executable size.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7380740243494852463?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7380740243494852463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7380740243494852463' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7380740243494852463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7380740243494852463'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/print-output.html' title='print output'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-9188288000983216166</id><published>2008-04-09T11:15:00.000-07:00</published><updated>2008-04-09T11:16:44.517-07:00</updated><title type='text'>LDAP Application Program Interface</title><content type='html'>The LDAP Application Program Interface, described by RFC 1823, is an Informational RFC that specifies an application programming interface in the C programming language for version 2 of the Lightweight Directory Access Protocol. Version 2 of LDAP is historic. Commonly available LDAP C APIs do not strictly adhere to this specification.&lt;br /&gt;&lt;br /&gt;see:-http://tools.ietf.org/html/rfc1823&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-9188288000983216166?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/9188288000983216166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=9188288000983216166' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9188288000983216166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/9188288000983216166'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/ldap-application-program-interface.html' title='LDAP Application Program Interface'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2294843689070103875</id><published>2008-04-06T02:16:00.000-07:00</published><updated>2008-04-06T02:33:48.437-07:00</updated><title type='text'>A* algorithm</title><content type='html'>/*This is the program showing implementation of a* algorithm, given n integers and a sum m ,write a program to find the set of integers summing to m using a* algorithm. */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #include&lt; stdio.h &gt;&lt;br /&gt; #include&lt; stdlib.h &gt;&lt;br /&gt; #include&lt; string.h &gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; char bln;&lt;br /&gt; int subsetsum(int*,int,int,char* ,int);&lt;br /&gt; int compare(const void*,const void*);&lt;br /&gt; void printanswer(int*,int,char*);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;   int a[]  = {5,3,4,8,9,6};&lt;br /&gt;   int sum  = 15;&lt;br /&gt;   int size = sizeof(a)/sizeof(*a);&lt;br /&gt;   int i;&lt;br /&gt;   char *selected = calloc(size,sizeof(*selected));&lt;br /&gt;&lt;br /&gt;   qsort(a,size,sizeof(int),compare);&lt;br /&gt;&lt;br /&gt;   for(i=0;i &lt; (size-1);i++)&lt;br /&gt;   {&lt;br /&gt;     printf("\n i = %d",i);&lt;br /&gt;&lt;br /&gt;     if( subsetsum(a,size,sum,selected,i))&lt;br /&gt;      printanswer(a,size,selected);&lt;br /&gt;&lt;br /&gt;     memset(selected,0,size * sizeof(*selected));&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int subsetsum(int *a,int n,int sum,char *selected ,int start)&lt;br /&gt; {&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   if(sum == 0)&lt;br /&gt;     return 1;&lt;br /&gt;&lt;br /&gt;   for(i=start;i &lt;= (n-1);i++)&lt;br /&gt;   if(selected[i] == 0 &amp;&amp; a[i] &lt;= sum)&lt;br /&gt;   {&lt;br /&gt;      selected[i] = 1;&lt;br /&gt;      if(subsetsum(a,n,sum - a[i],selected,i+1))&lt;br /&gt;      return 1;&lt;br /&gt;&lt;br /&gt;      selected[i] = 0;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   return 0;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void printanswer(int* a,int n,char* selected)&lt;br /&gt; {&lt;br /&gt;    int i;&lt;br /&gt;&lt;br /&gt;    for(i=0;i&lt; n;i++)&lt;br /&gt;     if(selected[i])&lt;br /&gt;  printf("\t%d",a[i]);&lt;br /&gt;&lt;br /&gt;    puts("");&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int compare(const void* e1,const void* e2)&lt;br /&gt; {&lt;br /&gt;    return *(int*)e2 - *(int*)e1;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;see:- http://www.policyalmanac.org/games/aStarTutorial.htm&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2294843689070103875?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2294843689070103875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2294843689070103875' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2294843689070103875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2294843689070103875'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/algorithm.html' title='A* algorithm'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2589347381545095424</id><published>2008-04-04T08:56:00.001-07:00</published><updated>2008-04-06T02:01:59.228-07:00</updated><title type='text'>padding and enums</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;arrays are guaranteed to be contiguous with no padding before or after any array member , but what about enums ..???&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An enumerated type is compatible with some implementation-defined integral type.  That type may have padding bits.  Is that what you're asking? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I just wanted to clear the doubt that, whether the concept structure padding also applies to enums ..??? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;walter roberson&lt;br /&gt;&lt;br /&gt;Your original wording about arrays is not completely correct.It is possible for there to be padding after the final array member in a structure. For example:&lt;br /&gt;&lt;br /&gt;struct foo { char bar[3]; int baz };&lt;br /&gt;&lt;br /&gt;then there could be padding after bar[2] and before baz.An enumeration type is some integral type (implementation-defined which),so the same rules apply to it as apply to other integral types. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;default user&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Enumerations are not an aggregate. The concept of padding means nothing in that context. It seems like you think that declaring an enum means making some data structure with all those in some sort of sequence. It doesn't. It creates a type, which is in reality some sort of alias for one of the integral types, with some predefined aliased values. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But that padding isn't part of the array.  In effect, there can be padding after the array, but not after an element of an array (a debatable distinction, but I think that's the best way to look at it)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;andrey tarasevich&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:&lt;br /&gt;&gt;  I just wanted to clear the doubt that, whether the concept structure padding also applies to enums ..???&lt;br /&gt;&lt;br /&gt;"Structure padding" is something that is inserted between small pieces (members) of a larger composite object. Such composite objects are referred as "aggregates" in C. Structures are aggregates, they can have padding between their members. Arrays are aggregates, although they cannot have any array-specific padding between their elements.&lt;br /&gt;&lt;br /&gt;Enums are not aggregates. They don't consist of smaller pieces. There's nowhere in enum you can insert that padding to. So I don't see how could anyone even start applying the concept of "struct padding" to enums.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CBFalconer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:&lt;br /&gt;&lt;br /&gt;&gt;  arrays are guaranteed to be contiguous with no padding before or  after any array member , but what about enums ..???&lt;br /&gt;&lt;br /&gt;No they are not. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What are not what?&lt;br /&gt;&lt;br /&gt;If you're disputing the statement that arrays are guaranteed to be contiguous, I'm afraid you're mistaken; there can be no padding before or after any array element.  (Depending on the context, there can be padding before or after the whole array, just as for any object.)&lt;br /&gt;&lt;br /&gt;If you're trying to answer the "what about enums" question, I'd like to know how you've managed to interpret the question so it has a meaningful yes or no answer. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;CBFalconer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If, for example, the basic element is an array of 3 bytes, but requires the alignment of 4, the individual element will be padded with an extra byte.  Something like:&lt;br /&gt;&lt;br /&gt;typedef struct elem {&lt;br /&gt;   int  i;&lt;br /&gt;   char c;&lt;br /&gt;&lt;br /&gt;} elem;&lt;br /&gt;&lt;br /&gt;and, to me, each element of:&lt;br /&gt;&lt;br /&gt;   elem array[MAX};&lt;br /&gt;&lt;br /&gt;will be padded accordingly.  This is why such arrays cannot be compared for equality with simple code. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Andrey tarasevich&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes, but this really has nothing much to do with the array itself. This trailing padding exists as an integral part of the above struct, not as something inserted additionally _between_ the elements of the array and specific to the the array itself.&lt;br /&gt;&lt;br /&gt;For arrays, the following relation must hold&lt;br /&gt;&lt;br /&gt;   sizeof array = sizeof element * number_of_elements&lt;br /&gt;&lt;br /&gt;This eliminates any possibility of the array inserting any additional padding between its elements. Any necessary padding should be already present in the element itself (in terms of it size, as returned by 'sizeof').&lt;br /&gt;&lt;br /&gt;&gt; and, to me, each element of:&lt;br /&gt;&lt;br /&gt;&gt;    elem array[MAX};&lt;br /&gt;&lt;br /&gt;&gt; will be padded accordingly.  This is why such arrays cannot be compared for equality with simple code.&lt;br /&gt;&lt;br /&gt;I'm not really sure what exactly you mean here. But if you are saying that arrays can't be compared by raw memory comparison because padding areas might contain unpredictable bit patterns, then first of all this issue actually already applies to structs. It already exists for standalone structs, no arrays necessary. And it applies to arrays of structs just as mere consequence of that, not because of some specific property of arrays.&lt;br /&gt;&lt;br /&gt;If array elements contain no padding of any kind (i.e. if they can be compared by raw memory comparison), then whole arrays of such elements can also be compared by raw memory comparison because, once again, arrays are not allowed to introduce any additional padding between their elements.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First off, your element type isn't an array of 3 bytes.  If it were,it would have to be byte-aligned.  For example:&lt;br /&gt;&lt;br /&gt;    typedef unsigned char tri_byte[3];&lt;br /&gt;    tri_byte arr[10];&lt;br /&gt;&lt;br /&gt;Type tri_byte cannot require 4-byte alignment, and sizeof arr must be 30 in any conforming implementation.  No padding is permitted within either array type.&lt;br /&gt;&lt;br /&gt;As for the example you actually used, I assume you intend sizeof(int)== 2.  If int requires word alignment, then sizeof(struct elem) must be (at least) 4; padding is inserted within the structure itself, probably after c (or possibly after i).  This padding is required because of the requirements on arrays, but it applies to all objects of type struct elem.&lt;br /&gt;&lt;br /&gt;Every object type must have a size that's a multiple of its required alignment.  Padding can exist within structures, but not between array elements.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard tobin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;CBFalconer wrote:&lt;br /&gt;&gt;&gt;&gt;&gt; arrays are guaranteed to be contiguous with no padding before or after any array member&lt;br /&gt;&lt;br /&gt;Note the phrase "before or after".&lt;br /&gt;&lt;br /&gt;&gt;typedef struct elem {&lt;br /&gt;&gt;   int  i;&lt;br /&gt;&gt;   char c;&lt;br /&gt;&gt;} elem;&lt;br /&gt;&lt;br /&gt;&gt;and, to me, each element of:&lt;br /&gt;&lt;br /&gt;&gt; elem array[MAX};&lt;br /&gt;&lt;br /&gt;&gt;will be padded accordingly.&lt;br /&gt;&lt;br /&gt;As you say, each element will be padded.  There will be no padding *before or after* each element.  The padding is *in* the elements.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Robbie Hatley&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"aarklon at gmail dot com" blythely made this abstraction error: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt; Arrays are guaranteed to be contiguous with no padding before &gt; or after any array member, but what about enums? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Arrays are objects. &lt;br /&gt;&lt;br /&gt;Enums are types. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Objects may have padding, or they may not. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Types, on the other hand, are incapable of either "having" or "not having" padding. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Perhaps you're confused by the fact that enums are declared using curly braces and lists of constant names, like so: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;enum Robbie &lt;br /&gt;{ &lt;br /&gt;   Alpha, &lt;br /&gt;   Bravo, &lt;br /&gt;   Charlie, &lt;br /&gt;   Delta, &lt;br /&gt;   Echo, &lt;br /&gt;   Foxtrot, &lt;br /&gt;   Golf &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That just defines "Alpha" as an alias for "0", "Bravo" as an alias for "1", etc.  It does not store any data,so there's no place to put any padding. &lt;br /&gt;&lt;br /&gt;Compare that to a struct instance: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;struct Bobbie &lt;br /&gt;{ &lt;br /&gt;   char Tom; &lt;br /&gt;   int  Jack; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;} Fred; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Object Fred will have (on most 32-bit machines and compilers)8 bytes:  1 byte for Tom, 3 bytes of padding, and 4 bytes for Jack.  That's so that the members of Fred start on word boundaries ("word" meaning the width of the CPU's registers). Makes the compiled program more efficient.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2589347381545095424?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2589347381545095424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2589347381545095424' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2589347381545095424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2589347381545095424'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/blog-post.html' title='padding and enums'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7291141561769107855</id><published>2008-04-03T09:39:00.000-07:00</published><updated>2008-04-04T09:02:46.963-07:00</updated><title type='text'>Towers of Hanoi</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nF2AQDhdiZc/R_UJDTaoDdI/AAAAAAAAAMw/xxevn8NVHPs/s1600-h/hanoi.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_nF2AQDhdiZc/R_UJDTaoDdI/AAAAAAAAAMw/xxevn8NVHPs/s320/hanoi.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5185060498343202258" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/R_UI7jaoDcI/AAAAAAAAAMo/LwF05X4oaBA/s1600-h/hanoi-trace.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/R_UI7jaoDcI/AAAAAAAAAMo/LwF05X4oaBA/s320/hanoi-trace.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5185060365199216066" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a simple program implementing towers of hanoi problem&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include&lt; stdio.h &gt;&lt;br /&gt; #include&lt; stdlib.h &gt;&lt;br /&gt;&lt;br /&gt; void toh(int,char,char,char);&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;  char source= 'A',temp = 'B', dest='C';&lt;br /&gt;&lt;br /&gt;  int n=4;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  toh(n,source,temp,dest);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void toh(int n,char s, char t,char d)&lt;br /&gt; {&lt;br /&gt;  if(n &gt; 0)&lt;br /&gt;  {&lt;br /&gt;    toh(n-1,s,d,t);&lt;br /&gt;    printf("\nmove disk %d %c ---&gt; %c",n,s,d);&lt;br /&gt;    toh(n-1,t,s,d);&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;#include "stdio.h"&lt;br /&gt;#include "stdlib.h"&lt;br /&gt;&lt;br /&gt;void move(int,char,char,char);&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;   int n,ch;&lt;br /&gt;&lt;br /&gt;  while(scanf("%d",&amp;n) != 1 )&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;     while( (ch = fgetc(stdin)) != EOF &amp;&amp; ch != '\n');&lt;br /&gt;     printf("\n Sorry, I couldn't read that");&lt;br /&gt;     printf("\n Please re-enter the values:: ");&lt;br /&gt;     fflush(stdout);&lt;br /&gt;     &lt;br /&gt;     if(scanf("%d",&amp;n) == 1)&lt;br /&gt;     break;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   move(n,'X','Y','Z');&lt;br /&gt;&lt;br /&gt;  return EXIT_SUCCESS;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; void move(int n,char x, char y, char z)&lt;br /&gt; {&lt;br /&gt;   &lt;br /&gt;   if(n == 1)&lt;br /&gt;       printf("\n Move disk from peg %c to peg %c",x,z);&lt;br /&gt;   else&lt;br /&gt;   {&lt;br /&gt;     move(n-1,x,z,y);&lt;br /&gt;     move(1,x,'',z);&lt;br /&gt;     move(n-1,y,x,z); &lt;br /&gt;   }  &lt;br /&gt; }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7291141561769107855?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7291141561769107855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7291141561769107855' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7291141561769107855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7291141561769107855'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/towers-of-hanoi.html' title='Towers of Hanoi'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nF2AQDhdiZc/R_UJDTaoDdI/AAAAAAAAAMw/xxevn8NVHPs/s72-c/hanoi.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8735017705570765424</id><published>2008-04-02T22:30:00.000-07:00</published><updated>2008-04-09T22:49:22.197-07:00</updated><title type='text'>Review of C elements of style,ISBN 8170293030, BPB publications</title><content type='html'>&lt;strong&gt;aarklon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I was going through the book "C Elements of style" by steve oualline.&lt;br /&gt;in this book many guidelines are given.the following were seen in the book as rules&lt;br /&gt;&lt;br /&gt;1) while(1) is preferred over for(;;)&lt;br /&gt;2) use of const is preferred over #define&lt;br /&gt;3) unless extreme efficiency is warranted, use printf instead of putc &amp; puts&lt;br /&gt;4) always split a for statement into 3 lines&lt;br /&gt;&lt;br /&gt;5) when splitting up a conditional clause(?:),write it on three lines: the condition line,the true-value line, and the false-value line.indent the last two lines an extra level&lt;br /&gt;&lt;br /&gt;6)allow no more than 5 parameters to a function&lt;br /&gt;7)avoid do/while use while and break instead.&lt;br /&gt;&lt;br /&gt;8)use the comma operator inside a for statement only to put together&lt;br /&gt;two statements. never use it to combine three statements&lt;br /&gt;&lt;br /&gt;9)always put a break at the end of the last case in a switch statement&lt;br /&gt;&lt;br /&gt;10) do not use absolute paths in #include directives. let the -I &lt;br /&gt;compile option do the work &lt;br /&gt;&lt;br /&gt;11) begin all debug printfs with ##  ex:- printf("## state=%d",state); &lt;br /&gt;&lt;br /&gt;12) the best indentation is 4 spaces &lt;br /&gt;&lt;br /&gt;13) if a macro contains more than one statement, use a do while structure to enclose the macro &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ex:- #define ABORT   \ &lt;br /&gt;      do{            \ &lt;br /&gt;      puts("abort"); \ &lt;br /&gt;      exit(8);       \ &lt;br /&gt;      }while(0); &lt;br /&gt;&lt;br /&gt;can anyone give examples for the justification of above rules ..????&lt;br /&gt;                           OR&lt;br /&gt; To what extent these rules are true..???&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="font-weight:bold;"&gt;while(1) is preferred over for(;;)&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;user923005&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I am opposite here. The constructs create identical results and the meaning for both is obvious. Some lints and compilers will whine about while (1) but they do not add any noise for for(;;).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(1) is an expression of somebody's personal preference,in the form of a rule. It seems to me to have as much force as "indent in multiples of three spaces" or "adverbAlways verbUse adjectiveHungarian nounNotation."&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Tobin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An experienced C programmer will of course be familiar with both, but I don't think the meaning of "for(;;)" is obvious. It doesn't follow from anything else that an empty continuation condition is true; the best you can do is say that it would be pointless if it worked the other way. "while(1)" on the other hand is not a special case at all.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Default user&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will lead to warnings in some cases. That being said, it's my preferred way.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;&lt;br /&gt;Richard Heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Balderdash. Preferred by him, possibly, but not by me. In the vanishingly rare circumstances where an infinite loop is appropriate, for(;;) expresses the intent without inducing some implementations to have a giddy fit over a constant conditional expression. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Marc mclntyre&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;any decent compiler will convert them into exactly the same opcodes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="font-weight:bold;"&gt;use of const is preferred over #define &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;user923005&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This one is obvious. #define can unexpectedly change something if you are not careful.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;2) has appeared in the draft CERT "Secure C Coding Standard," and some justification is given there. For what it's worth, I find the justifications unconvincing. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Flash Gordon&lt;/span&gt;&lt;br /&gt;The problem is that const does not introduce a compile time constant so it is not suitable for a lot of purposes and can cause confusion in others. I would say that (ab)using enum to create constants of type int has value and #define for the rest often makes more sense. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;defaultuser&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That won't work for array dimensions. There should at least be exceptions for that case. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If your compiler supports VLAs, it *will* work for array dimensions. &lt;br /&gt;And that could be a problem. &lt;br /&gt;"const" doesn't create a constant expression. If you don't need a constant expression (i.e., one that must be evaluable at compile time), then by all means use "const"; it's cleaner IMHO than #define.But if you need a constant expression, "const" just won't do the job. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Balderdash. Try it and see. &lt;br /&gt;const int MAX = 10; &lt;br /&gt;main() &lt;br /&gt;{ &lt;br /&gt; int class[MAX] = {0}; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The above code is carefully designed to break everywhere! But the reason it breaks differs depending on what language you're using. In C++, it's okay for an array size to be specified using a const (but you can't use class as an object name). In C99, it's okay to specify a variable-length array's size using a const (but the code breaks because implicit int has gone). But in C90, the code breaks because you can't use const to specify array sizes, which are a large part of what #defines are used for (and most of the other uses for #define are better dealt with by enum than by const). &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It breaks for the reasons you specify under any compiler that conforms to *some* standard. But if it weren't for one thing that you don't mention, it would compile without so much as a warning under at least one compiler that provides (in a non-conforming mode) several language extensions. &lt;br /&gt;That one thing is the initializer. Providing an initialization for a VLA is a constraint violation (C99 6.7.8p3). Which is too bad; being able to initialize it with the {0} idiom  would be handy. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Mark mclntyre&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Try using a const to define an array size (in C89), or as a case label. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Himanshu chauhan&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One benefit of using (2) I can see is, while debugging you can see the symbol rather than a value. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;unless extreme efficiency is warranted, use printf instead of putc &amp; puts&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;user923005&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Nonsense. If there is no format string, use puts(). If you are outputting a single character, use putc(). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(3)seems silly. It might make sense if inverted ("Don't switch from printf() to putchar() just for a tiny speed gain"), but in the actual form used ... Does this Rulemaker go on to recommend pow(x,2) instead of x*x, or pow(2,6) instead of 64?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Walter robinson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My -speculation- would be that the reasoning is that for text output, printf() appears so often that when putc() or puts() appears, people may have to stop and think about whether there is anything "special" or "magic" about what is being output or about the way that putc() or puts() operate so as to warrant the use of those functions instead of printf().For example, I see puts() seldom enough that I tend to forget that puts() adds \n automatically and then when I glance at code that uses puts() I tend to think, "Hold on, where's the \n ??" So there is some "magic" about puts() that has to be remembered. (especially as fputs() does not add a \n ). putc(), though, I personally find immediately obvious. &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;defaultuser&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I can't see why this would be preferable. Besides being possibly less efficient, printf() is often less readable and more prone to error. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;puts() also avoids problems like:   char *message = "Hello, %d world";   printf(message); But the solution to that is to understand who printf works. I have no strong preference one way or the other for printf vs. puts in cases where either will do the job. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;mark mclntyre&lt;/span&gt;&lt;br /&gt;again identical if you have a decent compiler. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No, it's the compiler that's relevant. A library implementation of printf can't avoid parsing the format string, even if it optimizes the case where there are no '%' characters. A compiler, on the other hand, can sometimes convert a printf call to an equivalent puts call. always split a for statement into 3 lines&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;always split a for statement into 3 lines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Flash gordon&lt;br /&gt;As an "always" I definitely disagree. In the simple case of something like: for (i=0; i &lt; lim; i++)it is completely pointless in my opinion. On some longer or more complex instances it can make sense to split it. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;5) when splitting up a conditional clause(?:),write it on three lines: the condition line,the true-value line, and the false-value line.indent the last two lines an extra level &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Flash gordon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Again, a stupid rule in my opinion. Think what it would do to... &lt;br /&gt;  fprintf(fp,"stuff %d more stuff",ptr?*ptr:0); &lt;br /&gt;&lt;br /&gt;Then imagine you have more parameters before and after that one. I come across requirements most easily implemented like this when producing interfacing files to be sent to other systems. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;allow no more than 5 parameters to a function &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Flash gordon&lt;br /&gt;A bit arbitrary and people will certainly argue about precisely what the limit should be, but makes more sense.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;avoid do/while use while and break instead. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;flash gordon&lt;br /&gt;&lt;br /&gt;This is just plain stupid. If the problems maps properly on to a &lt;br /&gt;do/while loop then use that rather than trying to bend some other &lt;br /&gt;construct to your needs. I don't use them very often, but when they are the correct construct they are the correct construct. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;8)use the comma operator inside a for statement only to put together two statements. never use it to combine three statements &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Flash gordon&lt;/span&gt;&lt;br /&gt;Again, rather arbitrary, people will definitely argue over what the limit should be. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;9)always put a break at the end of the last case in a switch statement&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Dan corbitt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My addition: &lt;br /&gt;a switch statement *must* contain a default branch, even if it only &lt;br /&gt;contains: &lt;br /&gt; default: &lt;br /&gt;   assert(0); &lt;br /&gt;   break; &lt;br /&gt;because you know it will never be exercised. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Ben pfaff&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have mixed feelings about this, because it (in my experience) defeats the ability of the compiler to remind you that you forgot to add a case for some value of an enumeration type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Tobin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Dann Corbit &lt;dcor...@connx.com&gt; wrote: &lt;br /&gt;&gt; a switch statement *must* contain a default branch, even if it only &lt;br /&gt;&gt; contains: &lt;br /&gt;&gt;  default: &lt;br /&gt;&gt;   assert(0); &lt;br /&gt;&gt;   break; &lt;br /&gt;&gt;because you know it will never be exercised. &lt;br /&gt;&lt;br /&gt;I often do that, but I wouldn't make it an absolute rule. For example, if the branches of a switch exhausted all the values of an enum, and I was confident that the variable only had instances of that enum assigned to it, I probably wouldn't bother with the default. Similarly, if an integer variable represented a boolean, I wouldn't bother to write &lt;br /&gt;&lt;br /&gt; if(t == 0) &lt;br /&gt;  ... false case ...; &lt;br /&gt; else if(t == 1) &lt;br /&gt;  ... true case ...; &lt;br /&gt; else &lt;br /&gt;  assert(0); &lt;br /&gt;&lt;br /&gt;even though a value of 2 would imply an bug just as much as an unexpected value in a switch. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;keith thompson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(Richard Tobin) writes: &lt;br /&gt;&gt; Dann Corbit  wrote: &lt;br /&gt;&gt;&gt;a switch statement *must* contain a default branch, even if it only &lt;br /&gt;&gt;&gt;contains: &lt;br /&gt;&gt;&gt;  default: &lt;br /&gt;&gt;&gt;   assert(0); &lt;br /&gt;&gt;&gt;   break; &lt;br /&gt;&gt;&gt;because you know it will never be exercised. &lt;br /&gt;&gt; I often do that, but I wouldn't make it an absolute rule. For &lt;br /&gt;&gt; example, if the branches of a switch exhausted all the values of an &lt;br /&gt;&gt; enum, and I was confident that the variable only had instances of that &lt;br /&gt;&gt; enum assigned to it, I probably wouldn't bother with the default. &lt;br /&gt;And, as others have pointed out, adding a "default:" might inhibit a &lt;br /&gt;warning if you leave something out. &lt;br /&gt;&gt; Similarly, if an integer variable represented a boolean, I wouldn't &lt;br /&gt;&gt; bother to write &lt;br /&gt;&gt;  if(t == 0) &lt;br /&gt;&gt;   ... false case ...; &lt;br /&gt;&gt;  else if(t == 1) &lt;br /&gt;&gt;   ... true case ...; &lt;br /&gt;&gt;  else &lt;br /&gt;&gt;   assert(0); &lt;br /&gt;&gt; even though a value of 2 would imply an bug just as much as an &lt;br /&gt;&gt; unexpected value in a switch. &lt;br /&gt;If t represents a boolean value, I wouldn't compare it to either 0 or &lt;br /&gt;1: &lt;br /&gt;  if (t) { &lt;br /&gt;    ... true case ... &lt;br /&gt;  } &lt;br /&gt;  else { &lt;br /&gt;    ... false case ... &lt;br /&gt;  } &lt;br /&gt;(Or use !t and reverse the order if you prefer.) &lt;br /&gt;For that matter, if t really is boolean, then a value of 2 *doesn't* necessarily imply a bug.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;if a macro contains more than one statement, use a do while structure to enclose the macro &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ex:- #define ABORT   \ &lt;br /&gt;      do{            \ &lt;br /&gt;      puts("abort"); \ &lt;br /&gt;      exit(8);       \ &lt;br /&gt;      }while(0); &lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Kenneth brody&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Doesn't that violate rule 7? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Chris Thomasson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt; How about: #define ABORT(msg, status) (puts(msg), exit(status)) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;keith thompson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Good advice, bad example.  Since a function call is an expression,there's no need for the do{}while(0) trick.  I'd write the above as: &lt;br /&gt;&lt;br /&gt;#define ABORT (puts("abort"), exit(8)) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(Assuming, of course, that 8 is a sensible exit value on the system I'm using, and that the "abort" message really should go to stdout rather than stderr.) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And didn't an earlier rule say to use printf rather than puts? Efficiency is hardly a concern if you're aborting the program. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The do-while trick is very useful when you can't avoid putting statements in a macro, but the "," and "?:" operators make it easier to avoid statements than you might think. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Finally, the semicolon at the end of the macro definition defeats the purpose of the do-while trick.  Is that really there in the book? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ben bacarisse&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I hope it does not include the ; at the end.  As you have it, &lt;br /&gt;&lt;br /&gt;  if (C) &lt;br /&gt;      ABORT; &lt;br /&gt;  else &lt;br /&gt;      go_on(); &lt;br /&gt;&lt;br /&gt;is a syntax error. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ben pfaff&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If you do this, then you should omit the ; at the end of the do...while statement.  Otherwise it defeats the purpose, because you cannot use the macro as if it were a statement. &lt;br /&gt;&lt;br /&gt;It is unconventional, in my experience, to define an object-like macro this way.  It would be more conventional to name it ABORT(), so that it looks like a function. &lt;br /&gt;&lt;br /&gt;The value 8 is not a portable exit status. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;aarklon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Ben Pfaff wrote: &lt;br /&gt;&lt;br /&gt;&gt; The value 8 is not a portable exit status. &lt;br /&gt;&lt;br /&gt;Then can you give examples for portable exit status, other than &lt;br /&gt;EXIT_FAILURE,EXIT_SUCCESS &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;walter roberson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;0 is the only other portable exit status. &lt;br /&gt;&lt;br /&gt;For example, under VMS, the exit status was logically divided into bit fields, with some of the bits assigned to represent the error severity, some of them to represent the facility, and some of them to represent the particular error for that facility. If you randomly choose an exit value, you could end up with some rather strange error messages getting printed out by the VMS CLI. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;aarklon&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;why 1 is not considered as a portable exit status, AFAIK exit(1)is usually used to indicate error conditions isn't it ...???? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Walter roberson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;"usually" is not the same as "portably". There are real operating systems (with real C compilers) for which exit(1) means something specific to the operating system. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ben pfaff&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;aarklon writes: &lt;br /&gt;&gt;&gt;Ben Pfaff  wrote: &lt;br /&gt;&lt;br /&gt;&gt;&gt;The value 8 is not a portable exit status. &lt;br /&gt;&gt;&gt;then can you give examples for portable exit status, other than &lt;br /&gt;&gt;&gt;EXIT_FAILURE,EXIT_SUCCESS &lt;br /&gt;&gt;&gt; 0 is the only other portable exit status. &lt;br /&gt;&lt;br /&gt;&gt;   why 1 is not considered as a portable exit status, AFAIK exit(1) &lt;br /&gt;&gt;  is usually used to indicate error conditions isn't it ...???? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is what the standard says: &lt;br /&gt;&lt;br /&gt;If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned.If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is what the rationale says: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The argument to exit is a status indication returned to the invoking environment.  In the UNIX operating system, a value of zero is the successful return code from a program.As usage of C has spread beyond UNIX, exit(0) has often been retained as an idiom indicating successful termination, even on operating systems with different &lt;br /&gt;systems of return codes.  This usage is thus recognized as standard.  There has never been a portable way of indicating a non-successful termination, since the &lt;br /&gt;arguments to exit are implementation-defined.The EXIT_FAILURE macro was added to C89 to provide such a capability.  EXIT_SUCCESS was added as well. &lt;br /&gt;&lt;br /&gt;As I understand it, on some operating systems, e.g. OpenVMS,particular return values are interpreted with specific and nuanced meanings, and so it is best not to wantonly return values other than the ones with standard meanings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;begin all debug printfs with ## &lt;br /&gt;ex:- printf("## state=%d",state); &lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eric sosman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;It's nice to distinguish them in *some* consistent way.It's also nice to mark "ordinary" messages in a way that aids automated scanning of log files and so on.  Also, consider whether such messages might be better on stderr than stdout.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;keith thompson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;That's one approach.  It's certainly not the only one.(Insert lengthy flame war about printf vs. debuggers.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;br /&gt;do not use absolute paths in #include directives. let the -I compile option do the work &lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Keith thompson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;That's good advice for those systems on which it's relevant.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;Eric sosman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Usually good, but follow established convention for the environment you're writing in.  E.g., POSIX code should &lt;br /&gt;include &lt;sys/types.h&gt; rather than &lt;types.h&gt;. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Ben pfaff&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I would ordinarily consider both sys/types.h and types.h to be relative paths.  /usr/include/sys/types.h would be an absolute path (and indeed, I avoid them in #include directives to the extent that I don't recall ever using one). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eric sosman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Yeah, I think the author's use of "absolute" is suspect. Most likely (it seems to me), he was talking about &lt;br /&gt;&lt;br /&gt;        #include "libfoo/foo.h" &lt;br /&gt;        #include "../../libbar/bar.h" &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;... and the like.Not "absolute" in any usual sense, but certainly "location-dependent." &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard heathfield&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Relatively absolute? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;joachim schmitz&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Absolutly relative!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;the best indentation is 4 spaces&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Keith thompson&lt;/strong&gt;&lt;br /&gt;That happens to be what I like, but I wouldn't argue that it's "the best".  Consistency is far more important than the choice of 4 vs. 3 vs. whatever. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Eric sosman&lt;/strong&gt;&lt;br /&gt;Does the author cite any research for this conclusion? The only study I've ever seen -- and it was long ago and I can no longer cite the source -- found that a two-space indent was too narrow and four just a bit too wide; that study's conclusion was that a three-space indent was most likely "best." &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard Heathfield&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The study was correct to identify that four space indent is too wide, but erroneous in recommending three spaces because, obviously, it has to be a power of two. One space is clearly too few, but two is just right.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Walter roberson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;3 is representable as a power of 2. Not an integral power, but you didn't specify integral power ;-)  (And if you had, some wag like me would have specified 1/2 a space, since -1 is integral.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;eric sosman&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt; ... but three *is* a power of two!  It's &lt;br /&gt;&lt;br /&gt;     &lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_nF2AQDhdiZc/R_i2PTaoDeI/AAAAAAAAAM4/z7Uxv9sy8DE/s1600-h/one.PNG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/R_i2PTaoDeI/AAAAAAAAAM4/z7Uxv9sy8DE/s320/one.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5186095344943369698" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now that I think of it, though, the study's conclusion was indeed probably wrong.  The interpolation should have been on the exponent, and the recommended indentation width should have been 2^1.5 = 2.82842712474619009760+ spaces.) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;default user&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Now, this is just insane. All right-thinking people know that the correct answer is "three". Everything else is morally repugnant and/or &lt;br /&gt;a terrorist plot. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;richard heathfield&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Anyone who is concerned that you may be part of some kind of comp.lang.c clique or cabal can now rest easy. No self-respecting cabalier would use a &lt;br /&gt;three-space indent. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;joachim schmitz&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;What's wrong with TAB? So everyone can adjust the tab width to his/her liking? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard Heathfield&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Firstly, it doesn't work terribly well on Usenet, since some news clients strip tabs out before display. Worse, some clients strip tabs out *before reply* - so it looks fine in the reader, but goes pear-shaped in a quote. &lt;br /&gt;&lt;br /&gt;Secondly, let's take an example like this: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  rc = myfunctioncall(arga, &lt;br /&gt;                      argb, &lt;br /&gt;                      argc); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;which looks lovely with spaces. Now let's try it with an eight-space tab (which I'm imitating with spaces, for the sake of Usenet clients!): &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        rc = myfunctioncall(arga, &lt;br /&gt;                            argb, &lt;br /&gt;                            argc); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If we replace those eight-space sequences with \t markers, we get this: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;\trc = myfunctioncall(arga, &lt;br /&gt;\t\t\t    argb, &lt;br /&gt;\t\t\t    argc); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That's fine, although it looks messy, because the editor will expand the tabs to eight spaces. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now let's use a three-space tab setting, and see what it expands to: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   rc = myfunctioncall(arga, &lt;br /&gt;             argb, &lt;br /&gt;             argc); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;argb and argc still line up with each other, of course, but they no longer line up with arga. So the three-space tabber takes code that was written with eight-space tabs and loads it into his editor, and much of the indentation is suddenly far less readable than the writer intended. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Either of these reasons is sufficient for a Usenetting programmer to stick to spaces, and the latter is, in my view, sufficient even for a non-Usenetting programmer, which is why I started using spaces-not-tabs some time before I began posting to Usenet (so it's just as well for me that the two reasons both point in the same direction!). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Incidentally, I generally set up my editor to convert tabs to spaces, so that I can still /use/ the TAB key. My decision to drop from a four-space indent to a two-space indent was a direct consequence of beginning to post to Usenet - I haven't yet found a newsreader that converts tabs to spaces (let alone a user-configurable number of spaces) on *writing*, and I got sick and tired of typing spacespacespacespace at the start of practically every code line. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Joachim schmitz&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I don't usually write code for Usenet (and if, I'd indeed rather use spaces &lt;br /&gt;and avoid // comments). And I guess most programmers don't. &lt;br /&gt;&lt;br /&gt;Not in my case&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8735017705570765424?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8735017705570765424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8735017705570765424' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8735017705570765424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8735017705570765424'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/c-elements-of-style.html' title='Review of C elements of style,ISBN 8170293030, BPB publications'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/R_i2PTaoDeI/AAAAAAAAAM4/z7Uxv9sy8DE/s72-c/one.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2930442476013174329</id><published>2008-04-02T08:08:00.000-07:00</published><updated>2008-04-02T08:16:24.039-07:00</updated><title type='text'>C certifications</title><content type='html'>&lt;strong&gt;sophia&lt;/strong&gt;&lt;br /&gt;where can i get a good/valid certification in C programming similar to the one given below&lt;br /&gt;&lt;a href="http://www.brainbench.com/xml/bb/common/testcenter/taketest.xml?testId=52"&gt;http://www.brainbench.com/xml/bb/common/testcenter/taketest.xml?testId=52&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Gerry Ford&lt;/strong&gt;&lt;br /&gt;The first thing I would do is turn to English orthography. The whole "certification" thing I associate outside of the C programming language. Maybe you can make it germane. --&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Richard Heathfield&lt;/strong&gt;&lt;br /&gt;Make up your mind - did you want a good test, or the test you mention? We looked at the Brainbench test some years ago, and identified a number of serious issues with it.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Santosh&lt;/strong&gt;&lt;br /&gt;Don't you think a certification with an institute is better than an online one? You'll find that in general online certifications are not well regarded.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Jack thomson&lt;/strong&gt;&lt;br /&gt;I'm a Brainbench C certified professional, believe me it doesn't make any difference. The only certifications that are considered valuable are the domain related certifications. Ex: Cisco Certifications.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Broli&lt;/strong&gt;&lt;br /&gt;Do you know of some institute/organization which provide such certifications in C ??&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;santosh&lt;/strong&gt;&lt;br /&gt;This depends on the country doesn't it? Usually for a job in country X, it's best to get a certification from a good organisation in country X. And even a small amount of actual experience is worth several certifications.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Jack Thomson&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;May be, i don't know about different country preferences, But brainbench is not a standard certification to go for, I just went for it when I was just out of my college hoping it could add a great value to my resume. But it doesn't add any value, no body actually knows about it, I was asked what is this Brainbench in almost all interviews... So I finally took it out of my resume :-(.&lt;br /&gt;If somebody wants to show their language and technical skill then I think writing their own tools and making it free source may add value, Since it shows that the candidate possesses most of the skills required for a project development.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2930442476013174329?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2930442476013174329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2930442476013174329' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2930442476013174329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2930442476013174329'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/04/c-certifications.html' title='C certifications'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8449884408750189423</id><published>2008-03-30T09:11:00.001-07:00</published><updated>2010-03-28T12:10:56.347-07:00</updated><title type='text'>rot-13 algorithm</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/S6-ptCptioI/AAAAAAAAB_0/UIBCrG3QX3k/s1600/rot13-algorithm.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 164px;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/S6-ptCptioI/AAAAAAAAB_0/UIBCrG3QX3k/s320/rot13-algorithm.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5453764265039989378" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8449884408750189423?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8449884408750189423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8449884408750189423' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8449884408750189423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8449884408750189423'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/super-grub-disk.html' title='rot-13 algorithm'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/S6-ptCptioI/AAAAAAAAB_0/UIBCrG3QX3k/s72-c/rot13-algorithm.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7916150574570800355</id><published>2008-03-27T23:49:00.000-07:00</published><updated>2008-03-27T23:55:59.235-07:00</updated><title type='text'>Diagram showing the working of recursive functions</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_hNduP9F5jm4/R-yWbqh0MSI/AAAAAAAAAA0/U1AEMBdkwZw/s1600-h/fib.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_hNduP9F5jm4/R-yWbqh0MSI/AAAAAAAAAA0/U1AEMBdkwZw/s320/fib.gif" alt="" id="BLOGGER_PHOTO_ID_5182682673213354274" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7916150574570800355?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7916150574570800355/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7916150574570800355' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7916150574570800355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7916150574570800355'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/diagram-showing-working-of-recursive.html' title='Diagram showing the working of recursive functions'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_hNduP9F5jm4/R-yWbqh0MSI/AAAAAAAAAA0/U1AEMBdkwZw/s72-c/fib.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-5856555329313107758</id><published>2008-03-27T02:27:00.001-07:00</published><updated>2009-08-02T09:49:14.344-07:00</updated><title type='text'>precedence rule for understanding C-declarations</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/SnXDfyHgwbI/AAAAAAAABdI/VZ-luTlHopc/s1600-h/precedence-rule.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 134px;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/SnXDfyHgwbI/AAAAAAAABdI/VZ-luTlHopc/s320/precedence-rule.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5365409481878454706" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SnXDaV0RrDI/AAAAAAAABdA/nEkzhw7jcR4/s1600-h/precedence-rule-1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SnXDaV0RrDI/AAAAAAAABdA/nEkzhw7jcR4/s320/precedence-rule-1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5365409388382235698" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-5856555329313107758?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/5856555329313107758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=5856555329313107758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5856555329313107758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5856555329313107758'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/master-boot-record.html' title='precedence rule for understanding C-declarations'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nF2AQDhdiZc/SnXDfyHgwbI/AAAAAAAABdI/VZ-luTlHopc/s72-c/precedence-rule.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2265012803824848426</id><published>2008-03-27T02:03:00.000-07:00</published><updated>2009-08-02T09:51:30.042-07:00</updated><title type='text'>magic decoder ring for C declarations</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nF2AQDhdiZc/SnXEBfkYfaI/AAAAAAAABdQ/RZbrlqtY7Is/s1600-h/magic-decoder-ring-for-cdecl.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 302px;" src="http://1.bp.blogspot.com/_nF2AQDhdiZc/SnXEBfkYfaI/AAAAAAAABdQ/RZbrlqtY7Is/s320/magic-decoder-ring-for-cdecl.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5365410061014826402" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2265012803824848426?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2265012803824848426/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2265012803824848426' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2265012803824848426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2265012803824848426'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/fixmbr-command-in-ms-dos.html' title='magic decoder ring for C declarations'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nF2AQDhdiZc/SnXEBfkYfaI/AAAAAAAABdQ/RZbrlqtY7Is/s72-c/magic-decoder-ring-for-cdecl.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6667187103113100232</id><published>2008-03-26T12:06:00.000-07:00</published><updated>2008-12-25T07:30:20.209-08:00</updated><title type='text'>Minimum height of a binary tree</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SVOm9bzzAVI/AAAAAAAAAzo/6And7kjV11c/s1600-h/Screenshot3.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SVOm9bzzAVI/AAAAAAAAAzo/6And7kjV11c/s320/Screenshot3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5283750362202964306" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6667187103113100232?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6667187103113100232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6667187103113100232' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6667187103113100232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6667187103113100232'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/ext3-browser.html' title='Minimum height of a binary tree'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/SVOm9bzzAVI/AAAAAAAAAzo/6And7kjV11c/s72-c/Screenshot3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2178506016363568180</id><published>2008-03-24T04:25:00.000-07:00</published><updated>2008-12-25T07:35:39.706-08:00</updated><title type='text'>Maximum height of a binary tree</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/SVOoIWUZGtI/AAAAAAAAAzw/GwA1i5eouNo/s1600-h/Screenshot4.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/SVOoIWUZGtI/AAAAAAAAAzw/GwA1i5eouNo/s320/Screenshot4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5283751649219254994" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2178506016363568180?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2178506016363568180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2178506016363568180' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2178506016363568180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2178506016363568180'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/un-managed-dll-functions-in-net-frame.html' title='Maximum height of a binary tree'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/SVOoIWUZGtI/AAAAAAAAAzw/GwA1i5eouNo/s72-c/Screenshot4.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-3248020286132560167</id><published>2008-03-24T01:06:00.000-07:00</published><updated>2008-03-24T01:28:40.511-07:00</updated><title type='text'>Tree Operations</title><content type='html'>1) to compute the no: of nodes in the binary tree&lt;br /&gt;   int count(struct node* node)&lt;br /&gt;   {&lt;br /&gt;        if(node == NULL)   return 0;&lt;br /&gt;       else&lt;br /&gt;        return( 1 + count(node-&gt; left) + count(node-&gt; right));&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;2) to count the internal nodes&lt;br /&gt;   int internal(tree* t)&lt;br /&gt;   {&lt;br /&gt;       if( (t==NULL)  ((t -&gt;left == NULL) &amp;amp;&amp;amp; (t -&gt; right == NULL)))&lt;br /&gt;         return 0;&lt;br /&gt;       else&lt;br /&gt;           return( 1 + internal(t -&gt; left) + internal(t -&gt; right) ); &lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;3) to count external nodes&lt;br /&gt;      int external(tree *t)&lt;br /&gt;     {&lt;br /&gt;       if(t == NULL)         return 0; &lt;br /&gt;        else&lt;br /&gt;            if( (t -&gt; left== NULL) &amp;amp;&amp;amp; (t -&gt;right == NULL))&lt;br /&gt;              return 1;&lt;br /&gt;            else&lt;br /&gt;               return(external(t -&gt; left) + external(t -&gt; right));&lt;br /&gt;       }&lt;br /&gt;3. /*  Compute the "maxDepth" of a tree -- the number of nodes along  the longest path from the root node down to the farthest leaf node. */&lt;br /&gt;&lt;br /&gt; int maxDepth(struct node* node)&lt;br /&gt; {&lt;br /&gt;     if (node==NULL) {     return(0);   }&lt;br /&gt;    else {     // compute the depth of each subtree &lt;br /&gt;                int lDepth = maxDepth(node-&gt;left);&lt;br /&gt;               int rDepth = maxDepth(node-&gt;right);&lt;br /&gt;             // use the larger one&lt;br /&gt;               if (lDepth &gt; rDepth) return(lDepth+1);&lt;br /&gt;               else return(rDepth+1);&lt;br /&gt;            }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;4)&lt;br /&gt;   /*   Given a non-empty binary search tree, return the minimum data value found in that tree.  Note that the entire tree does not need to be searched. */&lt;br /&gt;     int minValue(struct node* node)&lt;br /&gt;   {&lt;br /&gt;     struct node* current = node;&lt;br /&gt;     // loop down to find the leftmost leaf&lt;br /&gt;     while (current-&gt;left != NULL)  &lt;br /&gt;     {current = current-&gt;left;}&lt;br /&gt;     return(current-&gt;data);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;5)hasPathSum() Solution&lt;br /&gt;&lt;br /&gt;/*  Given a tree and a sum, return true if there is a path from the root  down to a leaf, such that adding up all the values along the path  equals the given sum.  Strategy: subtract the node value from the sum when recurring down,  and check to see if the sum is 0 when you run out of tree. */&lt;br /&gt;&lt;br /&gt;int hasPathSum(struct node* node, int sum)&lt;br /&gt; {   // return true if we run out of tree and sum==0&lt;br /&gt;         if (node == NULL) {  return(sum == 0);   }&lt;br /&gt;        else {   // otherwise check both subtrees &lt;br /&gt;                   int subSum = sum - node-&gt;data;&lt;br /&gt;                   return(hasPathSum(node-&gt;left, subSum)   hasPathSum(node-&gt;right, subSum));                    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;6) printPaths()&lt;br /&gt; /*  Given a binary tree, print out all of its root-to-leaf  paths, one per line. Uses a recursive helper to do the work. */&lt;br /&gt;&lt;br /&gt;void printPaths(struct node* node)&lt;br /&gt;{   int path[1000];&lt;br /&gt;   printPathsRecur(node, path, 0);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;/*  Recursive helper function -- given a node, and an array containing  the path from the root node up to but not including this node,  print out all the root-leaf paths. */&lt;br /&gt;&lt;br /&gt; void printPathsRecur(struct node* node, int path[], int pathLen)&lt;br /&gt; {   if (node==NULL) return;&lt;br /&gt;  // append this node to the path array&lt;br /&gt;     path[pathLen] = node-&gt;data;   pathLen++;&lt;br /&gt;  // it's a leaf, so print the path that led to here&lt;br /&gt;   if (node-&gt;left==NULL &amp;amp;&amp;amp; node-&gt;right==NULL)&lt;br /&gt;   {     printArray(path, pathLen);   }&lt;br /&gt;   else { &lt;br /&gt;              // otherwise try both subtrees &lt;br /&gt;              printPathsRecur(node-&gt;left, path, pathLen);&lt;br /&gt;             printPathsRecur(node-&gt;right, path, pathLen);&lt;br /&gt;           }&lt;br /&gt; }&lt;br /&gt;// Utility that prints out an array on a line.&lt;br /&gt; void printArray(int ints[], int len) {   int i;   for (i=0; i&lt;len; i++)&lt;br /&gt;{     printf("%d ", ints[i]);   }   printf("\n"); }  &lt;br /&gt;&lt;br /&gt;8. mirror() Solution&lt;br /&gt;/*  Change a tree so that the roles of the  left and right pointers are swapped at every node.&lt;br /&gt;&lt;br /&gt;  void mirror(struct node* node)&lt;br /&gt;  {&lt;br /&gt;      if (node==NULL) {     return;   }&lt;br /&gt;     else {   &lt;br /&gt;                struct node* temp;&lt;br /&gt;                 // do the subtrees &lt;br /&gt;                mirror(node-&gt;left);&lt;br /&gt;                mirror(node-&gt;right);&lt;br /&gt;               // swap the pointers in this node&lt;br /&gt;                temp = node-&gt;left;&lt;br /&gt;               node-&gt;left = node-&gt;right;&lt;br /&gt;               node-&gt;right = temp;&lt;br /&gt;          }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;9)&lt;br /&gt;     sameTree() Solution&lt;br /&gt;/*  Given two trees, return true if they are  structurally identical. */&lt;br /&gt;&lt;br /&gt; int sameTree(struct node* a, struct node* b)&lt;br /&gt; {   // 1. both empty -&gt; true&lt;br /&gt;      if (a==NULL &amp;amp;&amp;amp; b==NULL) return(true);&lt;br /&gt;  /* 2. both non-empty -&gt; compare them */&lt;br /&gt;     else&lt;br /&gt;      if (a != NULL &amp;amp;&amp;amp; b != NULL)&lt;br /&gt;    {  return(  a-&gt;data == b-&gt;data &amp;amp;&amp;amp;   sameTree(a-&gt;left, b-&gt;left) &amp;amp;&amp;amp; &lt;br /&gt;                        sameTree(a-&gt;right, b-&gt;right) );&lt;br /&gt;    }&lt;br /&gt;   // 3. one empty, one not -&gt; false&lt;br /&gt;&lt;br /&gt;   else return(false);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;10) /*  Returns true if a binary tree is a binary search tree. */&lt;br /&gt;int isBST(struct node* node)&lt;br /&gt;{&lt;br /&gt;    if (node==NULL) return(true);&lt;br /&gt;  /* false if the max of the left is &gt; than us */&lt;br /&gt;   if (node-&gt;left!=NULL &amp;amp;&amp;amp; maxValue(node-&gt;left) &gt; node-&gt;data)     return(false);&lt;br /&gt;  /*false if the min of the right is &lt;= than us   */&lt;br /&gt;  if (node-&gt;right!=NULL &amp;amp;&amp;amp; minValue(node-&gt;right) &lt;= node-&gt;data)     return(false);&lt;br /&gt;  // false if, recursively, the left or right is not a BST &lt;br /&gt;   if (!isBST(node-&gt;left)  !isBST(node-&gt;right))     return(false);&lt;br /&gt;  // passing all that, it's a BST&lt;br /&gt;   return(true);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-3248020286132560167?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/3248020286132560167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=3248020286132560167' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3248020286132560167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3248020286132560167'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/tree-operations.html' title='Tree Operations'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-833932960944070555</id><published>2008-03-20T01:27:00.000-07:00</published><updated>2009-01-12T11:05:37.002-08:00</updated><title type='text'>Euler tour traversal</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuUae3zSoI/AAAAAAAAA28/vOpCKXn-T9g/s1600-h/Screenshot5.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuUae3zSoI/AAAAAAAAA28/vOpCKXn-T9g/s320/Screenshot5.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5290485369961400962" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-833932960944070555?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/833932960944070555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=833932960944070555' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/833932960944070555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/833932960944070555'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/removing-kernel-images-in-ubuntu.html' title='Euler tour traversal'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuUae3zSoI/AAAAAAAAA28/vOpCKXn-T9g/s72-c/Screenshot5.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6798945925573600721</id><published>2008-03-20T01:05:00.000-07:00</published><updated>2009-01-12T11:03:33.961-08:00</updated><title type='text'>Printing an arithmetic expression</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuT-XkXolI/AAAAAAAAA20/mwE6AslIdtA/s1600-h/Screenshot3.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuT-XkXolI/AAAAAAAAA20/mwE6AslIdtA/s320/Screenshot3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5290484886964511314" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6798945925573600721?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6798945925573600721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6798945925573600721' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6798945925573600721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6798945925573600721'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/bsnl-broad-band-connection-in-ubuntu.html' title='Printing an arithmetic expression'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuT-XkXolI/AAAAAAAAA20/mwE6AslIdtA/s72-c/Screenshot3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6689549205733918104</id><published>2008-03-19T23:32:00.000-07:00</published><updated>2009-01-12T11:01:45.134-08:00</updated><title type='text'>in sufficiency of pre and post order</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuTjLJI_7I/AAAAAAAAA2s/2Es52tHYTOI/s1600-h/Screenshot6.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuTjLJI_7I/AAAAAAAAA2s/2Es52tHYTOI/s320/Screenshot6.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5290484419772612530" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6689549205733918104?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6689549205733918104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6689549205733918104' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6689549205733918104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6689549205733918104'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/how-to-restore-grub-from-live-ubuntu-cd.html' title='in sufficiency of pre and post order'/><author><name>defaultuser</name><uri>http://www.blogger.com/profile/10214285022062075341</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/SWuTjLJI_7I/AAAAAAAAA2s/2Es52tHYTOI/s72-c/Screenshot6.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-2154641597595949078</id><published>2008-03-18T23:58:00.000-07:00</published><updated>2009-01-12T10:59:57.951-08:00</updated><title type='text'>Binary tree creation special case</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nF2AQDhdiZc/SWuS4Q3q_jI/AAAAAAAAA2k/Bx09bn0imYE/s1600-h/Screenshot8.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_nF2AQDhdiZc/SWuS4Q3q_jI/AAAAAAAAA2k/Bx09bn0imYE/s320/Screenshot8.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5290483682575580722" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-2154641597595949078?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/2154641597595949078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=2154641597595949078' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2154641597595949078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/2154641597595949078'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/open-street-map.html' title='Binary tree creation special case'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nF2AQDhdiZc/SWuS4Q3q_jI/AAAAAAAAA2k/Bx09bn0imYE/s72-c/Screenshot8.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-966070610317783343</id><published>2008-03-18T11:47:00.000-07:00</published><updated>2008-03-18T12:01:41.245-07:00</updated><title type='text'>Stupid Indian  MCA Kids Question</title><content type='html'>&lt;span style="font-weight:bold;"&gt; Mention the type of applications which can be developed using C language?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Prakash T&lt;br /&gt;&lt;br /&gt;This is Prakash from in India at tamilnadu. I am a MCA Student.&lt;br /&gt;Please answer the Que: Mention the type of applications which can be developed using C language? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Thomas Mathews&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Gosh, that is going to be a huge list.Let us start off with two categories:  embedded systems and&lt;br /&gt;non-embedded (desktop, etc.).  Many applications can be developed for each category.  Now the task is to list uses of each category and that would lead to applications.&lt;br /&gt;&lt;br /&gt;Perhaps the easier question to answer is:  &lt;br /&gt;"What applications can't be written using the C language?"&lt;br /&gt;&lt;br /&gt;Here are some applications that can be wrriten, I know of:&lt;br /&gt;&lt;br /&gt;1. Operating systems.&lt;br /&gt;&lt;br /&gt;Enumerate at your risk.MS Windows, Linux, Unix, VxWorks, Nucleus Plus,VMS, MS-DOS, Vrtx, etc.&lt;br /&gt;&lt;br /&gt;2. Controllers (ahh, a wide field)&lt;br /&gt;&lt;br /&gt;Tape drives, disk drives, laser printers, ink jet printers, vending machines, microwave ovens, industrial mills, mailing machines, VCRs, DVD players, airplane controllers, car controllers, etc.&lt;br /&gt;&lt;br /&gt;3. Desktop applications (yes, another wide field)&lt;br /&gt;&lt;br /&gt;Video games, databases, database front-ends, spreadsheets,word processors, editors, image editors, architecture tools, schematic routers, assemblers, compilers,web &amp; internet applications.&lt;br /&gt;&lt;br /&gt;4. Scientific applications&lt;br /&gt;    {I don't have much knowledge in this arena.}&lt;br /&gt;&lt;br /&gt;I'm just curious how much time it will take you to enumerate or list all of the applications that can be written using the C language.  I think it might be one of those NP-Complete problems, such as finding the last digit of PI (3.14....). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;E Robert Tisdale&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Any application that can run on modern digital computers as long as there is a C compiler for the target computer. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Walter Roberson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;Prakash T. wrote:&lt;br /&gt;&gt;&gt; Mention the type of applications&lt;br /&gt;&gt;&gt; which can be developed using C language?&lt;br /&gt;&gt;Any application that can run on modern digital computers&lt;br /&gt;&gt;as long as there is a C compiler for the target computer.&lt;br /&gt;&lt;br /&gt;That's a close approximation, but not completely true -- at least not without using undefined behaviour or compiler extensions.&lt;br /&gt;&lt;br /&gt;Modern digital computers can have operations which are not part of the C language, and which are not representable in C.&lt;br /&gt;&lt;br /&gt;For example, if you have memory-mapped I/O (which is common), then you need the ability to convert numeric addresses into C pointers in order to perform the I/O. Now, for files that can be hidden in the implimentation of the C f*() routines such as fopen() and fwrite(), but anything beyond pure files (such as serial ports or graphics) is beyond the scope of fopen(),so even if the graphics can be responsably be handled via fopen()/fwrite() [rather than, e.g., being a video page written to directly] then one is getting into Undefined Behaviou.&lt;br /&gt;&lt;br /&gt;The same thing happens if you have special I/O instructions instead of memory-mapped I/O: you are only within the boundaries of the C standard when the library routines are talking to file subsystems.&lt;br /&gt;&lt;br /&gt;Thus, what can be implimented in *standard* C with no extensions is in actuality only a subset of what can be "run" on "modern digital computers". Roughly speaking, *standard* C corresponds [at most] to that which is "Turing computable".&lt;br /&gt;&lt;br /&gt;The problem with that is, as a friend of mine explored in depth in his PhD thesis, that the majority of computers do not "compute" particular results within the traditional meaning of Turing machines. &lt;br /&gt;&lt;br /&gt;What, for example, is a toaster "computing" ? Considering differences in moisture content and Brownian motion of air currents,and differences in thickness and slize of slices, a toaster isn't&lt;br /&gt;likely to get the same "inputs" twice in a row.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Erik De Castro lopo&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Absolutely anything.&lt;br /&gt;&lt;br /&gt;I'm a Linux user and I can point you to the following:&lt;br /&gt;&lt;br /&gt;   - the Linux kernel (99% C, the rest assembler)&lt;br /&gt;   - nearly all user space programs (bash shell, and most&lt;br /&gt;     command line tools).&lt;br /&gt;   - The GNU compiler collection (gcc, g++ etc).&lt;br /&gt;   - apache web server&lt;br /&gt;   - The X sindow system&lt;br /&gt;   - Most of the programs for the GNOME desktop&lt;br /&gt;   - mail servers (postfix, sendmail etc)&lt;br /&gt;   - filter servers (SAMBA, NFS)&lt;br /&gt;   - graphics manipulation (the gimp)&lt;br /&gt;   - email client programs (eg sylpheed)&lt;br /&gt;&lt;br /&gt;and probbly much more.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Stupidity revealed to the fullest extent......&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;sathyashrayan&lt;/span&gt;   &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;We have achieved a success in chess games. Thanks for the 9 GM from India. But regarding programming, that too in c and asm we still stand behind. I could see some c questions from Indian named posters in this Usenet. But comparing those questions with that of the questions asked and answers given by those experts in this Usenet responder, we are at the beginning.&lt;br /&gt;&lt;br /&gt;Programming is an art but not a science. A 10-year-old student can program well if he is given a proper training. There are lot of very young programmers in Europe, US, and other countries. If we look at the track records in this Usenet it will be more than 10 years.&lt;br /&gt;&lt;br /&gt;Once I wanted to learn the implementation of tree-data-struct. I tried several different ways and asked some help from this Usenet news group. In replay I got an American saying "&lt;span style="font-weight:bold;"&gt;WTF&lt;/span&gt; you are doing as a programming". WTF is an American expression.Then I went through his web site I come across the excellent work done by him in tree data-struct as a Stanford Grad student. I don't blame him for those words because if I would have been in his position I will have the same kind of expression. But I blame our system.&lt;br /&gt;&lt;br /&gt;My conclusion of that is the system that is been followed in India. MCA and BE students are considered as a programmers. But when I come across some MCA and BE students they don't even take the C and ASM programming as a serious one. Even if some body programs well then it is his or her own personal interest and self-study but not because of the way they have been thought. They will learn and write the data-struct as in the book without knowing the concept! Example: They&lt;br /&gt;will cast malloc()'s return and allocate mem. So taking the MCA and BE as a qualification is a bad for future Indian programmers.&lt;br /&gt;&lt;br /&gt;But I don't know about NCST teachings.&lt;br /&gt;&lt;br /&gt;In my view the industry's approach must change and there should be a school of programming as a full academics background India. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-966070610317783343?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/966070610317783343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=966070610317783343' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/966070610317783343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/966070610317783343'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/stupid-indian-mca-kids-question.html' title='Stupid Indian  MCA Kids Question'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6396875414391617063</id><published>2008-03-18T11:22:00.001-07:00</published><updated>2008-03-18T11:25:03.171-07:00</updated><title type='text'>Creating Tree from In-order and Pre-Order Traversals</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nF2AQDhdiZc/R-AI9Q2SeyI/AAAAAAAAAMg/c-Bx7pJLu8M/s1600-h/snapshot1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_nF2AQDhdiZc/R-AI9Q2SeyI/AAAAAAAAAMg/c-Bx7pJLu8M/s320/snapshot1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5179149420063783714" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nF2AQDhdiZc/R-AI4A2SexI/AAAAAAAAAMY/khAuuIe714M/s1600-h/snapshot2.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_nF2AQDhdiZc/R-AI4A2SexI/AAAAAAAAAMY/khAuuIe714M/s320/snapshot2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5179149329869470482" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/R-AIxw2SewI/AAAAAAAAAMQ/TSCagYJDIaQ/s1600-h/snapshot3.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/R-AIxw2SewI/AAAAAAAAAMQ/TSCagYJDIaQ/s320/snapshot3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5179149222495288066" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/R-AIqw2SevI/AAAAAAAAAMI/fegoebZss4c/s1600-h/snapshot4.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/R-AIqw2SevI/AAAAAAAAAMI/fegoebZss4c/s320/snapshot4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5179149102236203762" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nF2AQDhdiZc/R-AIig2SeuI/AAAAAAAAAMA/DnyUt-OSMmg/s1600-h/snapshot5.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_nF2AQDhdiZc/R-AIig2SeuI/AAAAAAAAAMA/DnyUt-OSMmg/s320/snapshot5.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5179148960502282978" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6396875414391617063?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6396875414391617063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6396875414391617063' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6396875414391617063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6396875414391617063'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/creating-tree-from-in-order-and-pre.html' title='Creating Tree from In-order and Pre-Order Traversals'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nF2AQDhdiZc/R-AI9Q2SeyI/AAAAAAAAAMg/c-Bx7pJLu8M/s72-c/snapshot1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-5952794715759602420</id><published>2008-03-16T10:26:00.000-07:00</published><updated>2010-04-12T09:22:44.902-07:00</updated><title type='text'>hierarchy of computer system software</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/S8NIzGLSutI/AAAAAAAACAk/gen4UDdpoMY/s1600/hierarchy-of-computer-system-sw.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/S8NIzGLSutI/AAAAAAAACAk/gen4UDdpoMY/s320/hierarchy-of-computer-system-sw.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5459287215971678930" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-5952794715759602420?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/5952794715759602420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=5952794715759602420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5952794715759602420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/5952794715759602420'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/bench-marking-your-ubuntu-system.html' title='hierarchy of computer system software'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/S8NIzGLSutI/AAAAAAAACAk/gen4UDdpoMY/s72-c/hierarchy-of-computer-system-sw.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1388517536723914026</id><published>2008-03-16T08:07:00.000-07:00</published><updated>2008-05-22T13:15:52.147-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1388517536723914026?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1388517536723914026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1388517536723914026' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1388517536723914026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1388517536723914026'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/swift-fox-installation-in-ubuntu.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-3728235727732175933</id><published>2008-03-16T02:41:00.000-07:00</published><updated>2008-05-22T13:14:57.726-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-3728235727732175933?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/3728235727732175933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=3728235727732175933' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3728235727732175933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3728235727732175933'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/get-list-of-installed-packages-in.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-805991276224467652</id><published>2008-03-16T02:08:00.000-07:00</published><updated>2008-05-22T13:13:17.620-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-805991276224467652?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/805991276224467652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=805991276224467652' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/805991276224467652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/805991276224467652'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/maximum-partitions-in-linux.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8578713941886593370</id><published>2008-03-15T20:27:00.000-07:00</published><updated>2008-05-29T10:32:39.412-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8578713941886593370?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8578713941886593370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8578713941886593370' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8578713941886593370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8578713941886593370'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/diposable-mail-id.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-366274088104512317</id><published>2008-03-15T20:22:00.000-07:00</published><updated>2008-05-29T10:29:54.473-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-366274088104512317?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/366274088104512317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=366274088104512317' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/366274088104512317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/366274088104512317'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/ikvmnet.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-4153646413061530159</id><published>2008-03-14T23:07:00.000-07:00</published><updated>2008-05-29T10:28:39.988-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-4153646413061530159?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/4153646413061530159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=4153646413061530159' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4153646413061530159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4153646413061530159'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/free-sms-from-web.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6418624596239438882</id><published>2008-03-14T22:34:00.000-07:00</published><updated>2008-05-22T13:12:14.393-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6418624596239438882?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6418624596239438882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6418624596239438882' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6418624596239438882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6418624596239438882'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/open-source-directories-repositories.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-3568528404507707957</id><published>2008-03-13T10:43:00.000-07:00</published><updated>2008-03-13T10:45:10.001-07:00</updated><title type='text'>Famous Software Failures</title><content type='html'>The following is a testimony to software failures and famous bugs...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Therac-25 (1985-1987)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Six people were overexposed during radiation treatments for cancer by Canada's Therac-25 radiation therapy machine.  Three of these patients were believed to have died from the overdoses.  The root cause was a lack of quality assurance, which lead to an over-complex, inadequately tested, under-documented system developed, and subsequently to the failure to take adequate corrective action. (Pooley &amp; Stevens, 1999)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;London Ambulance System (1992)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A succession of software engineering failures, especially in project management, caused 2 failures of London's (England) Ambulance dispatch system.  The repair cost was estimated at £9m, but it is believed that people died who would not have died if ambulances had reached them as promptly as they would have done without the failures.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Denver baggage handling system&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Denver airport baggage handling system was so complex (involving 300 computers) that the development overrun prevented the airport from opening on time.  Fixing the incredibly buggy system required an additional 50% of the original budget - nearly $200m.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Taurus (1993)&lt;/span&gt;&lt;br /&gt;Taurus, the planned automated transaction settlement system for the London Stock Exchange was canceled after 5 years of failed development.  Losses are estimated at £75m for the project and £450m to customers. (Pooley &amp; Stevens, 1999)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ariane 5 (1996)&lt;/span&gt;&lt;br /&gt;The Ariane 5 rocket exploded on its maiden flight in June [4], 1996 because the navigation package was inherited from the Ariane 4 without proper testing.  The new rocket flew faster, resulting in larger values of some variables in the navigation software.   Shortly after launch, an attempt to convert a 64-bit floating-point number into a 16-bit integer generated an overflow.  The error was caught, but the code that caught it elected to shut down the subsystem.  The rocket veered off course and exploded.   It was unfortunate that the code that failed genereated inertial reference information useful only before lift-off; had it been turned off at the moment of launch, there would have been no trouble. (Kernighan, 1999)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;E-mail buffer overflow (1998)&lt;/span&gt;&lt;br /&gt;Several E-mail systems suffer from a "buffer overflow error", when extremely long e-mail addresses are received.  The internal buffers receiving the addresses do not check for length and allow their buffers to overflow causing the applications to crash.  Hostile hackers use this fault to trick the computer into running a malicious program in its place.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;USS Yorktown (1998)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A crew member of the guided-missile cruiser USS Yorktown mistakenly entered a zero for a data value, which resulted in a division by zero.  The error cascaded and eventually shut down the ship's propulsion system.  The ship was dead in the water for several hours because a program didn't check for valid input.  (reported in Scientific American, November 1998)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Mars Climate Orbiter (September 23rd, 1999)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The 125 million dollar Mars Climate Orbiter is assumed lost by officials at NASA.  The failure responsible for loss of the orbiter is attributed to a failure of NASA’s system engineer process.  The process did not specify the system of measurement to be used on the project.  As a result, one of the development teams used Imperial measurement while the other used the metric system of measurement.  When parameters from one module were passed to another during orbit navigation correct, no conversion was performed, resulting in the loss of the craft. http://mars. jpl.nasa. gov/msp98/ orbiter/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-3568528404507707957?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/3568528404507707957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=3568528404507707957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3568528404507707957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3568528404507707957'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/famous-software-failures.html' title='Famous Software Failures'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-3922440047511653444</id><published>2008-03-13T10:37:00.000-07:00</published><updated>2008-11-12T02:42:02.863-08:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-3922440047511653444?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/3922440047511653444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=3922440047511653444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3922440047511653444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/3922440047511653444'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/biggest-secret-and-tips-of-major-brand.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6540288160460247271</id><published>2008-03-13T09:39:00.000-07:00</published><updated>2008-05-29T10:39:14.458-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6540288160460247271?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6540288160460247271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6540288160460247271' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6540288160460247271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6540288160460247271'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/carpal-tunnel-syndrome.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-4654799658937195460</id><published>2008-03-13T06:25:00.000-07:00</published><updated>2008-05-29T10:37:34.946-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-4654799658937195460?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/4654799658937195460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=4654799658937195460' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4654799658937195460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4654799658937195460'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/but-this-is-our-status-in-it-industry.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8648179799291083646</id><published>2008-03-11T22:21:00.000-07:00</published><updated>2008-05-22T13:09:40.275-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8648179799291083646?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8648179799291083646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8648179799291083646' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8648179799291083646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8648179799291083646'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/linux-boot-sequence.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-4968161283633599756</id><published>2008-03-11T22:15:00.000-07:00</published><updated>2008-03-13T05:13:21.047-07:00</updated><title type='text'>execute a different function before main()</title><content type='html'>&lt;span style="font-weight:bold;"&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hi all,&lt;br /&gt;recently i read the following passage in a site&lt;br /&gt;&lt;br /&gt;it is a compiler dependent thing if some feature is available that allows you to execute some function before main() is called. In turbo C compiler, there's one such fearture....the #pragma startup directive.&lt;br /&gt;I m giving an example of its use:-&lt;br /&gt;&lt;br /&gt;#include"stdio.h"&lt;br /&gt;void fun();&lt;br /&gt;#pragma startup fun&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;printf("Arun");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void fun()&lt;br /&gt;{&lt;br /&gt;printf("Anand \n");&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The o/p of the program given above will be :- Anand&lt;br /&gt;&lt;br /&gt;my question is there a standard way in ANSI-C&lt;br /&gt;to execute a different function before main() is called....?????? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Bos&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;No. But why would you? Call that function as the first thing you do in main() itself. The only reason I can think of why that wouldn't work is when you call main() recursively, and&lt;br /&gt;a) that's a very bad idea in the first place; b) the trivial workaround is left as an exercise for the reader. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Eric sosman&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes.  Two ways, in fact:&lt;br /&gt;&lt;br /&gt;1) Run your program in a freestanding environment, where "the name and type of the function called at program startup are implementation-defined."&lt;br /&gt;&lt;br /&gt;2) Use an editor to change the name of your existing main() to something else, and to change the name of your desired startup function to main().&lt;br /&gt;&lt;br /&gt;(Yes, this is somewhat tongue in cheek.  But there's a serious point behind it: If you can modify the program source, you are in control of what main() does.  You can therefore make it do whatever you wanted this other, magical function to do -- so you don't need any magic.) &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;aarklon&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;is it possible to modify the start up code in a hosted environment so as to change the name and type of the function called at program startup..???&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;santosh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have the source, yes. But you'll need to recompile and reinstall the library. Just what is your actual problem that apparently seems to be forcing you to massive hacks? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;walter robinson&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;aarklon&gt; wrote:&lt;br /&gt;&gt; is it possible to modify the start up code in a hosted environment&lt;br /&gt;&gt; so as to change the name and type of the function called at program&lt;br /&gt;&gt;startup..???&lt;br /&gt;&lt;br /&gt;It depends on the environment.&lt;br /&gt;&lt;br /&gt;[OT]&lt;br /&gt;&lt;br /&gt;For example on SGI IRIX, there is the following linker option:&lt;br /&gt;&lt;br /&gt;  -init ifuncsymbol&lt;br /&gt;        Puts a call to ifuncsymbol into the code that rld(5)&lt;br /&gt;        exercises before the main program begins.  The ifuncsymbol&lt;br /&gt;        contains initialization code to be called before control is&lt;br /&gt;        passed to main.  In the case of a DSO opened with dlopen(3C)&lt;br /&gt;        or sgidladd(3C) an initialization function is called after&lt;br /&gt;        the DSO is loaded but before it is referenced. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;George peter staplin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:&lt;br /&gt;&gt; Eric Sosman  wrote:&lt;br /&gt;&gt;&gt; aarklon wrote:&lt;br /&gt;&gt;&gt; &gt; Hi all,&lt;br /&gt;&gt;&gt; &gt; recently i read the following passage in a site&lt;br /&gt;&lt;br /&gt;&gt;&gt; &gt; it is a compiler dependent thing if some feature is available that&lt;br /&gt;&gt;&gt; &gt; allows you to execute some function before main() is called.&lt;br /&gt;&gt;&gt; &gt; In turbo C compiler, there's one such fearture....the #pragma startup&lt;br /&gt;&gt;&gt; &gt; directive.&lt;br /&gt;&gt;&gt; &gt; I m giving an example of its use:-&lt;br /&gt;&lt;br /&gt;&gt;&gt; &gt; #include"stdio.h"&lt;br /&gt;&gt;&gt; &gt; void fun();&lt;br /&gt;&gt;&gt; &gt; #pragma startup fun&lt;br /&gt;&gt;&gt; &gt; int main()&lt;br /&gt;&gt;&gt; &gt; {&lt;br /&gt;&gt;&gt; &gt; printf("Arun");&lt;br /&gt;&gt;&gt; &gt; }&lt;br /&gt;&gt;&gt; &gt; void fun()&lt;br /&gt;&gt;&gt; &gt; {&lt;br /&gt;&gt;&gt; &gt; printf("Anand \n");&lt;br /&gt;&gt;&gt; &gt; }&lt;br /&gt;&gt;&gt; &gt; The o/p of the program given above will be :- Anand&lt;br /&gt;&gt;&gt; &gt; my question is there a standard way in ANSI-C&lt;br /&gt;&gt;&gt; &gt; to execute a different function before main() is called....??????&lt;br /&gt;&lt;br /&gt;&gt;&gt;      Yes.  Two ways, in fact:&lt;br /&gt;&lt;br /&gt;&gt;&gt;1) Run your program in a freestanding environment, where&lt;br /&gt;&gt;&gt; "the name and type of the function called at program startup&lt;br /&gt;&gt;&gt; are implementation-defined."&lt;br /&gt;&lt;br /&gt;&gt;  is it possible to modify the start up code in a hosted environment&lt;br /&gt;&gt;  so as to change the name and type of the function called at program&lt;br /&gt;&gt; startup..???&lt;br /&gt;&lt;br /&gt;Yes, it's possible with a hosted environment but not from standard C.&lt;br /&gt;&lt;br /&gt;When a program is loaded with most (Windows and Unix-like) systems, the OS jumps to an offset for _start in assembly code.&lt;br /&gt;&lt;br /&gt;If you're using gcc in Windows or a POSIX system you can see what startup files gcc links with via: gcc -v somefile.c&lt;br /&gt;&lt;br /&gt;The startup files are typically named like crt0.o.  They are implemented in assembly code usually and the various crt*.o do tasks like implementing exit(main(argc,argv)); and setting up the environment&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Wang cong&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It depends on the environment.&lt;br /&gt;Sure. In gcc you can use __attribute__((constructor)). ;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;santosh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;no, because different implementations will do this differently. Even for Linux the start-up sequence is very different under x86 and Itanium. For hosted implementations the system will typically jump into a predefined entry point in your program. This normally enters the initialisation code of your C runtime library that will linked in with your program. Often the entry point is specified in source with the label _start:. This code does some system specific initialisation and ten calls the function called main, which of course, then enter your&lt;br /&gt;program. After you return from main, fall of it's end, or call exit,_Exit or abort, execution once again enters the shutdown code in your C library, which may do a whole host of things like flushing streams, closing file handles, calling handlers registered with atexit etc.,before finally handing control over to the host system.&lt;br /&gt;&lt;br /&gt;To know the details you need to look at the source for your system C runtime library. The details are very system specific and no one explanation will suffice. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Kenneth brody&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;aarklon wrote:-&lt;br /&gt;&lt;br /&gt;&gt; it is a compiler dependent thing if some feature is available that &lt;br /&gt;&gt; allows you to execute some function before main() is called.&lt;br /&gt;&gt; In turbo C compiler, there's one such fearture....the #pragma startup&lt;br /&gt;&gt; directive.&lt;br /&gt;&gt; I m giving an example of its use:-&lt;br /&gt;&lt;br /&gt;&gt; #include&lt;stdio.h&gt;&lt;br /&gt;&gt; void fun();&lt;br /&gt;&gt; #pragma startup fun&lt;br /&gt;[...]&lt;br /&gt;&gt; my question is there a standard way in ANSI-C &lt;br /&gt;&gt; to execute a different function before main() is called....??????&lt;br /&gt;&lt;br /&gt;I assume you want something equivalent to atexit(), which lets you specify functions to call after exit() [or a return from main()]? Obviously, unlike atexit(), you can't have your function call a&lt;br /&gt;function to tell it to do so.&lt;br /&gt;&lt;br /&gt;You can't do this in any standard way.  The closest thing you can do is to simply call them at the very top of main().&lt;br /&gt;&lt;br /&gt;Can you specify more than one "#pragma startup", and call more than one function before main()?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;[Warning: Untested code follows. Typos may be present. I leave it&lt;br /&gt;as an exercise for the reader to fix them.]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you only need a single function, why not declare some global variable:&lt;br /&gt;&lt;br /&gt;    extern void (*RunAtStartup)(void);&lt;br /&gt;&lt;br /&gt;At the start of main, add:&lt;br /&gt;&lt;br /&gt;    if ( RunAtStartup != NULL )&lt;br /&gt;        (*RunAtStartup)();&lt;br /&gt;&lt;br /&gt;Then, in whatever module needs this special startup function, you include:&lt;br /&gt;&lt;br /&gt;    extern void TheFunctionINeed(void);&lt;br /&gt;    void (*RunAtStartup)(void) = TheFunctionINeed;&lt;br /&gt;&lt;br /&gt;Unfortunately, this only works if there is only a single function that needs to be run.  If you need more than one, then you need to build an array of function pointers, all in one place, in which case you might as well just call the functions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-4968161283633599756?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/4968161283633599756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=4968161283633599756' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4968161283633599756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4968161283633599756'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/execute-different-function-before-main.html' title='execute a different function before main()'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-6239080933776897589</id><published>2008-03-11T10:56:00.000-07:00</published><updated>2008-03-13T04:56:34.464-07:00</updated><title type='text'>Merge sort</title><content type='html'>/* Program of sorting using merge sort through recursion*/&lt;br /&gt;&lt;br /&gt;#include"stdlib.h"&lt;br /&gt;#include"stdio.h"&lt;br /&gt;#define MAX 20&lt;br /&gt;void merge (int[], int, int, int);&lt;br /&gt;void merge_sort (int[], int, int);&lt;br /&gt;int&lt;br /&gt;main (void)&lt;br /&gt;{&lt;br /&gt;  int i, n, a[MAX], ch;&lt;br /&gt;  printf ("Enter the number of elements : ");&lt;br /&gt;  fflush (stdout);&lt;br /&gt;  while (scanf ("%d", &amp;n) != 1)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;      while ((ch = fgetc (stdin)) != EOF &amp;&amp; ch != '\n');&lt;br /&gt;      printf ("\n Sorry, I couldn't read that");&lt;br /&gt;      printf ("\n Please re-enter the values:: ");&lt;br /&gt;      fflush (stdout);&lt;br /&gt;      if (scanf ("%d", &amp;n) == 1)&lt;br /&gt;        break;&lt;br /&gt;    }&lt;br /&gt;for (i = 0; i &lt; n; i++)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;      printf ("Enter element %d : ", i);&lt;br /&gt;      fflush (stdout);&lt;br /&gt;      while (scanf ("%d", &amp;a[i]) != 1)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;          while ((ch = fgetc (stdin)) != EOF &amp;&amp; ch != '\n');&lt;br /&gt;          printf ("\n Sorry, I couldn't read that");&lt;br /&gt;          printf ("\n Please re-enter the values:: ");&lt;br /&gt;          fflush (stdout);&lt;br /&gt;          if (scanf ("%d", &amp;a[i]) == 1)&lt;br /&gt;            break;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;  printf ("\nUnsorted list is :");&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    printf ("%d\t", a[i]);&lt;br /&gt;  merge_sort (a, 0, n - 1);&lt;br /&gt;  printf ("\nSorted list is :");&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;   printf ("%d\t", a[i]);&lt;br /&gt;  puts ("");&lt;br /&gt;  return EXIT_SUCCESS;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;merge_sort (int a[MAX], int low, int high)&lt;br /&gt;{&lt;br /&gt;  int mid;&lt;br /&gt;  if (low != high)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;      mid = (low + high) / 2;&lt;br /&gt;      merge_sort (a, low, mid);&lt;br /&gt;      merge_sort (a, mid + 1, high);&lt;br /&gt;      merge (a, low, mid, high);&lt;br /&gt;    }&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;merge (int a[MAX], int low, int mid, int high)&lt;br /&gt;{&lt;br /&gt;  int temp[MAX];&lt;br /&gt;  int i = low;&lt;br /&gt;  int j = mid + 1;&lt;br /&gt;  int k = low;&lt;br /&gt;  while ((i &lt;= mid) &amp;&amp; (j &lt;= high))&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;      if (a[i] &lt;= a[j])&lt;br /&gt;        temp[k++] = a[i++];&lt;br /&gt;&lt;br /&gt;      else&lt;br /&gt;        temp[k++] = a[j++];&lt;br /&gt;    }                           /*End of while */&lt;br /&gt;  while (i &lt;= mid)&lt;br /&gt;    temp[k++] = a[i++];&lt;br /&gt;  while (j &lt;= high)&lt;br /&gt;    temp[k++] = a[j++];&lt;br /&gt;  for (i = low; i &lt;= high; i++)&lt;br /&gt;    a[i] = temp[i];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Dann corbitt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This sort routine has to be recompiled for every new sized array.&lt;br /&gt;&lt;br /&gt;&gt; int i = low;&lt;br /&gt;&gt; int j = mid + 1;&lt;br /&gt;&gt; int k = low;&lt;br /&gt;&gt; while ((i &lt;= mid) &amp;&amp; (j &lt;= high))&lt;br /&gt;&lt;br /&gt;&gt; {&lt;br /&gt;&gt; if (a[i] &lt;= a[j])&lt;br /&gt;&gt; temp[k++] = a[i++];&lt;br /&gt;&lt;br /&gt;&gt; else&lt;br /&gt;&gt; temp[k++] = a[j++];} /*End of while */&lt;br /&gt;&lt;br /&gt;&gt; while (i &lt;= mid)&lt;br /&gt;&gt; temp[k++] = a[i++];&lt;br /&gt;&gt; while (j &lt;= high)&lt;br /&gt;&gt; temp[k++] = a[j++];&lt;br /&gt;&gt; for (i = low; i &lt;= high; i++)&lt;br /&gt;&gt; a[i] = temp[i];&lt;br /&gt;&lt;br /&gt;&gt; }- Hide quoted text -&lt;br /&gt;&lt;br /&gt;&gt; - Show quoted text -&lt;br /&gt;&lt;br /&gt;If you want simplicity then maybe something like this:&lt;br /&gt;/*&lt;br /&gt;** The following routines are for a horrible but easily understandable&lt;br /&gt;** form of merge-sort.   Here, we actually join the ordered data&lt;br /&gt;*/&lt;br /&gt;template &lt; class Etype &gt;&lt;br /&gt;void            MMERGE(Etype A[], Etype B[], size_t l, size_t m,&lt;br /&gt;size_t r)&lt;br /&gt;{&lt;br /&gt;    size_t          i = l;&lt;br /&gt;    size_t          j = m + 1;&lt;br /&gt;    size_t          k = l;&lt;br /&gt;    /* Put the smallest thing into array B */&lt;br /&gt;    while ((i &lt;= m) &amp;&amp; (j &lt;= r)) {&lt;br /&gt;        if (A[i] &lt; A[j])        /* Etype needs a &lt; operator. */&lt;br /&gt;            B[k++] = A[i++];&lt;br /&gt;        else&lt;br /&gt;            B[k++] = A[j++];&lt;br /&gt;    }&lt;br /&gt;    /* Copy leftover (if any) */&lt;br /&gt;    while (i &lt;= m) {&lt;br /&gt;        B[k++] = A[i++];&lt;br /&gt;    }&lt;br /&gt;    while (j &lt;= r) {&lt;br /&gt;        B[k++] = A[j++];&lt;br /&gt;    }&lt;br /&gt;    /* Transfer back to original array */&lt;br /&gt;    for (k = l; k &lt;= r; k++) {&lt;br /&gt;        A[k] = B[k];&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Helper function for icky(tm) merge sort */&lt;br /&gt;template &lt; class Etype &gt;&lt;br /&gt;void            MSORT(Etype A[], Etype B[], size_t l, size_t r)&lt;br /&gt;{&lt;br /&gt;    size_t          m;          /* The middle */&lt;br /&gt;    if (l &lt; r) {                /* Cut problem to half size until 1&lt;br /&gt;unit */&lt;br /&gt;        /* Divide partition by 2, sort and merge */&lt;br /&gt;        m = ((l + r) &gt;&gt; 1);&lt;br /&gt;        MSORT(A, B, l, m);&lt;br /&gt;        MSORT(A, B, m + 1, r);&lt;br /&gt;        MMERGE(A, B, l, m, r);  /* A single element is ordered */&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#ifdef UNIT_TEST&lt;br /&gt;#define M_S_SIZE 10000000&lt;br /&gt;int             a[M_S_SIZE];&lt;br /&gt;int             t[M_S_SIZE];&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;cstdlib&gt;&lt;br /&gt;#include &lt;ctime&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;int             checksort(int arr[], size_t arr_size)&lt;br /&gt;{&lt;br /&gt;    size_t          i;&lt;br /&gt;    for (i = 0; i &lt; arr_size - 1; i++) {&lt;br /&gt;        if (arr[i] &gt; arr[i + 1]) {&lt;br /&gt;            cout &lt;&lt; "OUT OF SORT!  arr[" &lt;&lt; i &lt;&lt; "] = " &lt;&lt; arr[i] &lt;&lt; "&lt;br /&gt;arr[" &lt;&lt; i + 1 &lt;&lt; "] = " &lt;&lt; arr[i + 1] &lt;&lt; endl;&lt;br /&gt;            return 0;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    return 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int             main(void)&lt;br /&gt;{&lt;br /&gt;    size_t          i;&lt;br /&gt;    time_t          start,&lt;br /&gt;                    end;&lt;br /&gt;    double          delta;&lt;br /&gt;    srand(time(NULL));&lt;br /&gt;    for (i = 0; i &lt; M_S_SIZE; i++)&lt;br /&gt;        a[i] = rand();&lt;br /&gt;    start = time(NULL);&lt;br /&gt;    MSORT(a, t, 0, M_S_SIZE - 1);&lt;br /&gt;    delta = difftime(time(NULL), start);&lt;br /&gt;    cout &lt;&lt; "Mergesort used " &lt;&lt; delta &lt;&lt; " seconds to sort " &lt;&lt;&lt;br /&gt;M_S_SIZE &lt;&lt; " values." &lt;&lt; endl;&lt;br /&gt;    checksort(a, M_S_SIZE);&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;If you want a really useful sort, then examine the possibility of external merge sorting. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Gene&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can do the job with half the temporary space (or less) and less code.  Sorry this is in Ada rather than C or C++.  But it is not too hard to recode.  'First in C is 0 (the first index of the array). Similarly  'Last and 'Length have the obvious meaning.  Ada arrays allow arbitrary index ranges.  Declare creates a new scope variables in the middle of code.&lt;br /&gt;&lt;br /&gt;   procedure Sort(List : in out List_Type) is&lt;br /&gt;      Mid, First : Positive;&lt;br /&gt;   begin&lt;br /&gt;      if List'Length &gt; 1 then&lt;br /&gt;         Mid := (List'First + List'Last) / 2;&lt;br /&gt;         Sort(List(List'First .. Mid));&lt;br /&gt;         Sort(List(Mid + 1 .. List'Last));&lt;br /&gt;&lt;br /&gt;         -- Find index of merge start (efficiency hack).&lt;br /&gt;         First := List'First;&lt;br /&gt;         while List(First) &lt; List(Mid + 1) loop&lt;br /&gt;            First := First + 1;&lt;br /&gt;         end loop;&lt;br /&gt;&lt;br /&gt;         -- Merge.&lt;br /&gt;         declare&lt;br /&gt;            Temp : List_Type := List(First .. Mid);&lt;br /&gt;            P1 : Positive := First;&lt;br /&gt;            P2 : Positive := Mid + 1;&lt;br /&gt;            I  : Positive := First;&lt;br /&gt;         begin&lt;br /&gt;            while P1 &lt;= Mid loop&lt;br /&gt;               if P2 &gt; List'Last or else Temp(P1) &lt; List(P2) then&lt;br /&gt;                  List(I) := Temp(P1);&lt;br /&gt;                  P1 := P1 + 1;&lt;br /&gt;               else&lt;br /&gt;                  List(I) := List(P2);&lt;br /&gt;                  P2 := P2 + 1;&lt;br /&gt;               end if;&lt;br /&gt;               I := I + 1;&lt;br /&gt;            end loop;&lt;br /&gt;         end;&lt;br /&gt;      end if;&lt;br /&gt;   end Sort;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-6239080933776897589?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/6239080933776897589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=6239080933776897589' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6239080933776897589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/6239080933776897589'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/merge-sort.html' title='Merge sort'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-8352742665314909516</id><published>2008-03-10T10:48:00.000-07:00</published><updated>2008-03-10T10:52:53.054-07:00</updated><title type='text'>binary tree from array</title><content type='html'>/* This program illustrates the concept of creating binary tree from array*/&lt;br /&gt;&lt;br /&gt;#include "stdio.h"&lt;br /&gt;#include "stdlib.h"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;typedef struct node&lt;br /&gt;{&lt;br /&gt;  struct node *left;&lt;br /&gt;  char data;&lt;br /&gt;  struct node *right;&lt;br /&gt;} sn;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sn *buildtree (int);&lt;br /&gt;void inorder (sn *);&lt;br /&gt;void freetree (sn *);&lt;br /&gt;&lt;br /&gt;char a[] = {&lt;br /&gt;  'Z', 'X', 'C', 'V', 'B', 'N', 'M', '\0', '\0', 'A', '\0',&lt;br /&gt;  '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main (void)&lt;br /&gt;{&lt;br /&gt;  struct node *root;&lt;br /&gt;  root = buildtree (0);&lt;br /&gt;  printf ("In-order Traversal:\n");&lt;br /&gt;  inorder (root);&lt;br /&gt;  puts ("");&lt;br /&gt;  freetree (root);&lt;br /&gt;  return EXIT_SUCCESS;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sn *&lt;br /&gt;buildtree (int n)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  sn *temp = NULL;&lt;br /&gt;  if (a[n] != '\0')&lt;br /&gt;    {&lt;br /&gt;      temp = malloc (sizeof (*temp));&lt;br /&gt;      if (temp == NULL)&lt;br /&gt;        {&lt;br /&gt;          printf ("Error\nmalloc failed");&lt;br /&gt;          exit (1);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;      temp-&gt;left = buildtree (2 * n + 1);&lt;br /&gt;      temp-&gt;data = a[n];&lt;br /&gt;      temp-&gt;right = buildtree (2 * n + 2);&lt;br /&gt;    }&lt;br /&gt;  return temp;&lt;br /&gt;}&lt;br /&gt;void&lt;br /&gt;inorder (sn * root)&lt;br /&gt;{&lt;br /&gt;  if (root != NULL)&lt;br /&gt;    {&lt;br /&gt;      inorder (root-&gt;left);&lt;br /&gt;      printf ("%c\t", root-&gt;data);&lt;br /&gt;      inorder (root-&gt;right);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;freetree (sn * root)&lt;br /&gt;{&lt;br /&gt;  if (root != NULL)&lt;br /&gt;    {&lt;br /&gt;      freetree(root-&gt;left);&lt;br /&gt;      freetree(root-&gt;right);&lt;br /&gt;    }&lt;br /&gt;  free (root);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-8352742665314909516?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/8352742665314909516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=8352742665314909516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8352742665314909516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/8352742665314909516'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/binary-tree-from-array.html' title='binary tree from array'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-590032314590753910</id><published>2008-03-10T10:27:00.000-07:00</published><updated>2008-03-10T10:40:16.520-07:00</updated><title type='text'>Application BInary interface</title><content type='html'>In computer software, an application binary interface (ABI) describes the low-level interface between an application program and the operating system, or the interface between an application and its libraries, or that between component parts of an application. An ABI is similar to an application programming interface (API), however the latter defines a source code interface.[1] Simply put, ABIs enable binary compatibility, whereas APIs enable source code compatibility.&lt;br /&gt;&lt;br /&gt;see:&lt;br /&gt;developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/Articles/32bitPowerPC.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-590032314590753910?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/590032314590753910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=590032314590753910' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/590032314590753910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/590032314590753910'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/application-binary-interface.html' title='Application BInary interface'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-4680108782861410986</id><published>2008-03-09T07:00:00.000-07:00</published><updated>2008-03-09T07:01:25.687-07:00</updated><title type='text'>indegree and outdegree of each node of a graph</title><content type='html'>/*&lt;br /&gt; * Program to compute the indegree and outdegree of each node of a graph&lt;br /&gt; * by using adjacency matrix  representation of graph&lt;br /&gt; *&lt;br /&gt; * */&lt;br /&gt;&lt;br /&gt;#include"stdio.h"&lt;br /&gt;#include"stdlib.h"&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;buildadj (int a[][10], int n)&lt;br /&gt;{&lt;br /&gt;  int i, j;&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    for (j = 0; j &lt; n; j++)&lt;br /&gt;      {&lt;br /&gt;        printf ("Enter 1 if there is a node from %d to %d else 0\n:: ", i, j);&lt;br /&gt;        scanf ("%d", &amp;a[i][j]);&lt;br /&gt;      }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;outdegree (int adj[][10], int x, int n)&lt;br /&gt;{&lt;br /&gt;  int i, count = 0;&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    if (adj[x][i] == 1)&lt;br /&gt;      count++;&lt;br /&gt;&lt;br /&gt;  return count;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;indegree (int adj[][10], int x, int n)&lt;br /&gt;{&lt;br /&gt;  int i, count = 0;&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    if (adj[i][x] == 1)&lt;br /&gt;      count++;&lt;br /&gt;&lt;br /&gt;  return count;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main (void)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  int adj[10][10];&lt;br /&gt;  int i, n;&lt;br /&gt;&lt;br /&gt;  printf ("\nEnter the no: of nodes(max 10) :: ");&lt;br /&gt;  scanf ("%d", &amp;n);&lt;br /&gt;&lt;br /&gt;  buildadj (adj, n);&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; puts (""), i++)&lt;br /&gt;    {&lt;br /&gt;      printf ("\n Out-Degree of the node = %d", outdegree (adj, i, n));&lt;br /&gt;      printf ("\n In-Degree of the node = %d", indegree (adj, i, n));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;  puts ("");&lt;br /&gt;  return (EXIT_SUCCESS);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-4680108782861410986?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/4680108782861410986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=4680108782861410986' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4680108782861410986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/4680108782861410986'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/indegree-and-outdegree-of-each-node-of.html' title='indegree and outdegree of each node of a graph'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1844890331866603105</id><published>2008-03-09T06:59:00.001-07:00</published><updated>2008-03-09T06:59:54.613-07:00</updated><title type='text'>Depth first traversal</title><content type='html'>/*&lt;br /&gt; * Program to compute depth first traversal  of a graph&lt;br /&gt; * it makes use of an array visited of n elements where&lt;br /&gt; *  n is the no: of vertices of the graph and the elements are boolean&lt;br /&gt; *  if visited[i] = 1 then it means that ith vertex is visited&lt;br /&gt; * */&lt;br /&gt;&lt;br /&gt;#include"stdio.h"&lt;br /&gt;#include"stdlib.h"&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;buildadj (int a[][10], int n)&lt;br /&gt;{&lt;br /&gt;  int i, j;&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    for (j = 0; j &lt; n; j++)&lt;br /&gt;      {&lt;br /&gt;        printf ("Enter 1 if there is a node from %d to %d else 0\n:: ", i, j);&lt;br /&gt;        scanf ("%d", &amp;a[i][j]);&lt;br /&gt;      }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;dfs (int x, int visited[10], int adj[][10], int n)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  int j;&lt;br /&gt;  visited[x] = 1;&lt;br /&gt;  printf ("node visited id = %d\t", x);&lt;br /&gt;&lt;br /&gt;  for (j = 0; j &lt; n; j++)&lt;br /&gt;    if (adj[x][j] == 1 &amp;&amp; visited[j] == 0)&lt;br /&gt;      {&lt;br /&gt;        /* printf("\n adj[%d][%d]",x,j); */&lt;br /&gt;        dfs (j, visited, adj, n);&lt;br /&gt;      }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main (void)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  int adj[10][10];&lt;br /&gt;  int i, j, n, visited[10];&lt;br /&gt;&lt;br /&gt;  printf ("\nEnter the no: of nodes(max 10) :: ");&lt;br /&gt;  scanf ("%d", &amp;n);&lt;br /&gt;&lt;br /&gt;  buildadj (adj, n);&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; puts (""), i++)&lt;br /&gt;    for (j = 0; j &lt; n; j++)&lt;br /&gt;      printf ("%d\t", adj[i][j]);&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    visited[i] = 0;&lt;br /&gt;&lt;br /&gt;  for (i = 0; i &lt; n; i++)&lt;br /&gt;    if (visited[i] == 0)&lt;br /&gt;      dfs (i, visited, adj, n);&lt;br /&gt;  &lt;br /&gt;  puts ("");&lt;br /&gt;  return (EXIT_SUCCESS);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1844890331866603105?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1844890331866603105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1844890331866603105' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1844890331866603105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1844890331866603105'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/depth-first-traversal.html' title='Depth first traversal'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1108227606349382765</id><published>2008-03-09T06:50:00.000-07:00</published><updated>2008-03-09T07:03:37.236-07:00</updated><title type='text'>padding and arrays</title><content type='html'>&lt;span style="font-weight:bold;"&gt;sophia&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;arrays are guaranteed to be contiguous with no padding before or after any array member&lt;br /&gt;Is it because all the elements are of the same type ?&lt;br /&gt;&lt;br /&gt;now consider this&lt;br /&gt;&lt;br /&gt;int a[] = {10,20,30,40,50};&lt;br /&gt;float f = 3.14f;&lt;br /&gt;void *p[]= {&amp;a[1],&amp;a[0],&amp;a[2],&amp;a[4],&amp;f};&lt;br /&gt;&lt;br /&gt;now my question is In all cases all the elements of p will be stored contiguous with no padding before or after any array member ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;mark bluemel&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You've said p is an array of pointers to void. Why should you expect them to be stored otherwise? How they are initialised is not important.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;.5.7 of C89: "All the expressions in an initializer for an object that has static storage duration or in an initializer list for an object that has aggregate or union type shall be constant expressions."&lt;br /&gt;&lt;br /&gt;An array has aggregate type.&lt;br /&gt;&lt;br /&gt;3.4: "   More latitude is permitted for constant expressions in initializers.  Such a constant expression shall evaluate to one of the following:&lt;br /&gt;&lt;br /&gt; * an arithmetic constant expression,&lt;br /&gt;&lt;br /&gt; * an address constant, or&lt;br /&gt;&lt;br /&gt; * an address constant for an object type plus or minus an integral&lt;br /&gt;   constant expression.&lt;br /&gt;&lt;br /&gt;[...] An address constant is a pointer to an lvalue designating an object of static storage duration, or to a function designator".&lt;br /&gt;&lt;br /&gt;So the initialization of p[] is illegal (but does not violate a constraint, so no diagnostic message is required, but the behaviour of the program is undefined).&lt;br /&gt;&lt;br /&gt;You could fix this by making a[] and f static.&lt;br /&gt;&lt;br /&gt;Once you've done that, the answer is "yes" - p[] will be an array of five void *, each of which occupies exactly sizeof(void *) bytes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Tobin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The elements of p are still all the same type: they're all void *.The fact that they're initialized from values of other types doesn't change that.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1108227606349382765?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1108227606349382765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1108227606349382765' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1108227606349382765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1108227606349382765'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/padding-and-arrays.html' title='&lt;span style=&quot;font-weight:bold;&quot;&gt;padding and arrays&lt;/span&gt;'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-1613335364018631243</id><published>2008-03-06T21:53:00.000-08:00</published><updated>2008-03-07T02:37:07.968-08:00</updated><title type='text'>what will be the o/p</title><content type='html'>what will be the output of &lt;br /&gt;&lt;br /&gt; #include "stdio.h"&lt;br /&gt; #include "stdlib.h"&lt;br /&gt;&lt;br /&gt; int main(void)&lt;br /&gt; {&lt;br /&gt;   int a[] = {10,20,30,40,50};&lt;br /&gt;   int *p;&lt;br /&gt;   p = (int*)((char*)a + sizeof(int));&lt;br /&gt;   &lt;br /&gt;   printf("%d",*p);&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;This question may have different answers depending on the compiler used(16/32 bit) and the processor used&lt;br /&gt;&lt;br /&gt;case 1:-  &lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;a 32 bit compiler and a little endian machine&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;here sizeof int  will be 4. now &lt;span style="font-weight:bold;"&gt;a&lt;/span&gt; points to first element in the array i.e  10 ( 00001010 00000000 00000000 00000000) and (char*)a points to 00001010. &lt;br /&gt;now (char*)a + 4 means   (char*)a + 4 * sizeof(char) &lt;br /&gt;i.e (char*)a + 4  points to 4 byte positions away from the current position i.e it will point to byte position (00010100) of 20(00010100 00000000 00000000 00000000 ) so output will be 20 itself&lt;br /&gt;&lt;br /&gt;case 2:- &lt;span style="font-weight:bold;"&gt;a 16 bit compiler and a little endian machine&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here size of int will be 2 now &lt;span style="font-weight:bold;"&gt;a&lt;/span&gt; points to the first element in the array i.e 10 now (char *)a + 2 points to 2 byte positions away from the current position i.e it will point to lower byte position of 20 1.e( 00010100 00000000) so output will be 20 itself&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Richard Heathfield&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;int a[] = {10,20,30,40,50}; defines an array of int with five elements.&lt;br /&gt;int *p; defines a pointer to int.&lt;br /&gt;a yields &amp;a[0], the address of the lowest-address byte in the a array,&lt;br /&gt;which is guaranteed to be aligned correctly for int because it's an int&lt;br /&gt;array.&lt;br /&gt;&lt;br /&gt;(char *)a yields the same address, but with type char *.&lt;br /&gt;Because arrays are guaranteed to be contiguous with no padding before or&lt;br /&gt;after any array member, (char *)a + sizeof(int) yields the address of the&lt;br /&gt;second int in the array, with type char *. Again, this is guaranteed to be&lt;br /&gt;aligned correctly for int.&lt;br /&gt;&lt;br /&gt;(int *) yields the same address as its operand, but with type int *.&lt;br /&gt; p = assigns that address to p.&lt;br /&gt;printf("%d", *p); will write "20" to the standard output device.&lt;br /&gt;Guaranteed. (Well, printf can fail, and of course there's no newline, but&lt;br /&gt;you know what I mean.) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ian collins&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No, it will not. p points the the second int in the array, byte order (or sizeof int ) has no effect.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Robert Hatley&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;   int a[]  = {10,20,30,40,50};&lt;br /&gt;   int b    = 0;&lt;br /&gt;&lt;br /&gt;   b = (int)(*((char*)a + sizeof(int)));&lt;br /&gt;   printf("%d\n", b);&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;the pointer is now a char pointer, not an int pointer, so when you dereference it with the "*" I think it gives the byte that it points to (the lowest-RAM-address byte of the "20"), cast back to an int.  So I think it will print "20" for little-endian and "0" for big-endian,regardless of sizeof(int).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/R9EaBg2SeKI/AAAAAAAAAHs/nR5-ktcs7vw/s1600-h/snapshot11.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/R9EaBg2SeKI/AAAAAAAAAHs/nR5-ktcs7vw/s320/snapshot11.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5174946060125239458" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nF2AQDhdiZc/R9Eatg2SeLI/AAAAAAAAAH0/HFg7fhc2l3g/s1600-h/snapshot12.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_nF2AQDhdiZc/R9Eatg2SeLI/AAAAAAAAAH0/HFg7fhc2l3g/s320/snapshot12.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5174946816039483570" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-1613335364018631243?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/1613335364018631243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=1613335364018631243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1613335364018631243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/1613335364018631243'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/what-will-be-op.html' title='what will be the o/p'/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_nF2AQDhdiZc/R9EaBg2SeKI/AAAAAAAAAHs/nR5-ktcs7vw/s72-c/snapshot11.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4825298097849543272.post-7226613418141366825</id><published>2008-03-06T05:24:00.000-08:00</published><updated>2008-05-29T10:41:37.993-07:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4825298097849543272-7226613418141366825?l=aarkloninfo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aarkloninfo.blogspot.com/feeds/7226613418141366825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4825298097849543272&amp;postID=7226613418141366825' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7226613418141366825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4825298097849543272/posts/default/7226613418141366825'/><link rel='alternate' type='text/html' href='http://aarkloninfo.blogspot.com/2008/03/google-tips.html' title=''/><author><name>aarklon</name><uri>http://www.blogger.com/profile/14737940988373030781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_nF2AQDhdiZc/Sl1O5YWlETI/AAAAAAAABVQ/hB9NlfvE620/S220/OAAAAJqSVX_df_Biw5qyitR7G35Jkttld1TwetvyqT-YPxGl_FqYuylAHJ9TM02oLogCBZqAoMxAnqg1-xZFX9q9mR4Am1T1UELvSVPhudFOJ9EcNveSorfb3FZr.jpg'/></author><thr:total>0</thr:total></entry></feed>
