<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5846472446395912215</atom:id><lastBuildDate>Fri, 30 Aug 2024 06:33:28 +0000</lastBuildDate><category>C</category><category>OOSI</category><category>java</category><category>object oriented system implementation</category><category>polumorphism</category><category>getclass</category><category>instanceof</category><category>object oriented implementation</category><category>pointers</category><category>polymorphism</category><title>Al&#39;s take on tech</title><description></description><link>http://alinnovate.blogspot.com/</link><managingEditor>noreply@blogger.com (alokadvin)</managingEditor><generator>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-1198187252568948049</guid><pubDate>Sat, 12 Jan 2008 08:22:00 +0000</pubDate><atom:updated>2008-01-12T00:25:02.456-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">object oriented system implementation</category><category domain="http://www.blogger.com/atom/ns#">OOSI</category><category domain="http://www.blogger.com/atom/ns#">polumorphism</category><title>Design and Implementation Idea of POLYMORPHISM in C [ non - object oriented language] Part IV</title><description>DISCUSSION – &lt;br /&gt;&lt;br /&gt;1.A function pointer restricts (via the function prototype) the type of parameters passed to the function it is pointing to. One can use void pointer parameters to allow for varying parameter types, but this decreases the code readability (i.e. function prototypes include void pointer arguments instead of meaningful types) and disables parameter type checking.&lt;br /&gt;&lt;br /&gt;2.Code Reuse is largely possible. If some new type comes in we don’t need to modify the original source code.&lt;br /&gt;&lt;br /&gt;3.User programming is relatively simpler ... but implementation programming is quite difficult because of the large number of referencing and dereferencing of pointers to function that are highly required here.&lt;br /&gt;&lt;br /&gt;4.Polymorphism thus obtained can be used with other data structure objects as well. It can be used with more then one layer of dependence i.e. objects hierarchy. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Another Approach -&lt;br /&gt;&lt;br /&gt;Another approach is to introduce a common structure, which will be passed as parameter to the polymorphic function, hiding all type-dependant data in a special field of this structure. This special field is usually a void pointer or a union and is used as private storage space for each implementation of the polymorphic function.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is all for polymorphism in C for time being. Hope you would benefit from the post. Do write me your suggestions and remarks.&lt;br /&gt;&lt;br /&gt;xoxo&lt;br /&gt;aL</description><link>http://alinnovate.blogspot.com/2008/01/design-and-implementation-idea-of_7287.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-5386394960987824380</guid><pubDate>Sat, 12 Jan 2008 08:16:00 +0000</pubDate><atom:updated>2008-01-12T00:21:43.357-08:00</atom:updated><title>Design and Implementation Idea of POLYMORPHISM in C [ non - object oriented language] Part III</title><description>Implementation&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_SIZE_STACK 100&lt;br /&gt;&lt;br /&gt;// here for a basic type only two methods are considered i.e. get() and print()&lt;br /&gt;// and their corresponding index in the virtual_table are as&lt;br /&gt;#define COUNT_METHOD  2&lt;br /&gt;&lt;br /&gt;#define METHOD_GET 0&lt;br /&gt;#define METHOD_PRINT    1&lt;br /&gt;&lt;br /&gt;// defining general type i.e. super class for the different types&lt;br /&gt;&lt;br /&gt;/***************** General type ***************************/&lt;br /&gt;&lt;br /&gt;struct general_type {&lt;br /&gt;// vtable is a pointer to an array of pointers to functions which takes in pointer to&lt;br /&gt;// a general type and returns int&lt;br /&gt;int (*(*pvtable)[COUNT_METHOD])(struct general_type *);&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;// creating an array of size COUNT_METHOD to pointers of function&lt;br /&gt;typedef int  (*vtable_general_type[COUNT_METHOD])(struct general_type *);&lt;br /&gt;&lt;br /&gt;/************* methods for general_type *********************/&lt;br /&gt;&lt;br /&gt;// constructor for general_type object&lt;br /&gt;&lt;br /&gt;int general_type_ctor(struct general_type * this) {&lt;br /&gt;// setting up the virtual table field&lt;br /&gt;this-&gt;pvtable = (vtable_general_type *)malloc(sizeof(vtable_general_type));&lt;br /&gt;this-&gt;pvtable[0][0] = NULL;&lt;br /&gt;this-&gt;pvtable[0][1] = NULL;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/******************** specific_type1 *************************/&lt;br /&gt;&lt;br /&gt;struct specific_type1 {&lt;br /&gt;int (*(*pvtable)[COUNT_METHOD])(struct specific_type1 *);&lt;br /&gt;&lt;br /&gt;&lt;/string.h&gt;&lt;/stdlib.h&gt;&lt;/stdio.h&gt;&lt;br /&gt;&lt;br /&gt;int data;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;/************* methods for specific_type1 *********************/&lt;br /&gt;typedef int  (*vtable_specific_type1[COUNT_METHOD])(struct general_type *);&lt;br /&gt;&lt;br /&gt;// constructor for specific_type1 object&lt;br /&gt;int specific_type1_ctor(struct specific_type1 * this) {&lt;br /&gt;// it&#39;s constructor first calls the constructor of the base class&lt;br /&gt;general_type_ctor((struct general_type *) this); // typecasting &quot;this&quot;&lt;br /&gt;this-&gt;data = 0;&lt;br /&gt;/* set up vtable field */&lt;br /&gt;this-&gt;pvtable = (vtable_specific_type1 *)malloc(sizeof(vtable_specific_type1));&lt;br /&gt;this-&gt;pvtable[0][0] = &amp;amp;specific_type1_get;&lt;br /&gt;this-&gt;pvtable[0][1] = &amp;amp;specific_type1_print;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int specific_type1_get(struct specific_type1 * this) {&lt;br /&gt;/* Implement the input of object this  */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int specific_type1_print(struct specific_type1 * this) {&lt;br /&gt;/* Implement the output of object this  */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/******************** specific_type2 *************************/&lt;br /&gt;struct specific_type2 {&lt;br /&gt;int (*(*vtable)[COUNT_METHOD])(struct specific_type2 *);&lt;br /&gt;float data;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;/************* methods for specific_type2 *********************/&lt;br /&gt;&lt;br /&gt;// constructor for specific_type1 object&lt;br /&gt;int specific_type2_ctor(struct specific_type2 * this) {&lt;br /&gt;/* implement it&#39;s constructor similarly as the previous one */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int specific_type2_get(struct specific_type2 * this) {&lt;br /&gt;/* Implement the input of object this  */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int specific_type2_print(struct specific_type2 * this) {&lt;br /&gt;/* Implement the output of object this  */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/***********************************************************************/&lt;br /&gt;/********  stack implementation using general type *********************/&lt;br /&gt;/***********************************************************************/&lt;br /&gt;&lt;br /&gt;typedef struct _stack {&lt;br /&gt; // stack has pointer to an array of general type&lt;br /&gt; // and also has the last index&lt;br /&gt; struct general_type *list[MAX_SIZE_STACK];&lt;br /&gt; int top;&lt;br /&gt;} stack;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;stack * stack_initialize() {&lt;br /&gt; int i;&lt;br /&gt; stack * s;&lt;br /&gt; s = (stack *)malloc(sizeof(stack));&lt;br /&gt; for(i=0; i&lt;max_size_stack;&gt;list[i] = (struct general_type *)malloc(sizeof(struct general_type));&lt;br /&gt; }&lt;br /&gt; s-&gt;top = -1;&lt;br /&gt; return s;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;struct general_type * top_of_stack(stack * s) {&lt;br /&gt; struct general_type * temp;&lt;br /&gt; if(s-&gt;top&lt;0&gt;list[s-&gt;top] == NULL )&lt;br /&gt;   temp = NULL;&lt;br /&gt; else&lt;br /&gt;   temp = s-&gt;list[s-&gt;top];&lt;br /&gt;&lt;br /&gt; return temp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;stack * push(stack * s, struct general_type * new) {&lt;br /&gt;s-&gt;top ++;&lt;br /&gt;s-&gt;list[s-&gt;top] = memcpy(s-&gt;list[s-&gt;top],new,sizeof(struct general_type));&lt;br /&gt;return s;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;stack * pop(stack * s) {&lt;br /&gt; // error condition if s-&gt;top &lt;= 0   s-&gt;top --;&lt;br /&gt; return s;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**********************************************************************/&lt;br /&gt;/****** main program to check the working of heterogeneous stack ******/&lt;br /&gt;/**********************************************************************/&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt; stack *s;&lt;br /&gt; struct general_type * gt1, *gt2;&lt;br /&gt; struct specific_type1 * st1a, * st1b; // making instances&lt;br /&gt; struct specific_type2 * st2a, * st2b;&lt;br /&gt;&lt;br /&gt; // initializing stack&lt;br /&gt; s = stack_initialize();&lt;br /&gt;&lt;br /&gt; // doing some known operations&lt;br /&gt;&lt;br /&gt; st1a = (struct specific_type1 *)malloc(sizeof(struct specific_type1)); // allocating memory&lt;br /&gt; specific_type1_ctor(st1a); // calling constructor for setting appropriate vtables&lt;br /&gt;&lt;br /&gt; st1b = (struct specific_type1 *)malloc(sizeof(struct specific_type1));&lt;br /&gt; specific_type1_ctor(st1b);&lt;br /&gt;&lt;br /&gt; st2a = (struct specific_type2 *)malloc(sizeof(struct specific_type2)); // allocating memory&lt;br /&gt; specific_type2_ctor(st2a); // calling constructor for setting appropriate vtables&lt;br /&gt;&lt;br /&gt; // to fetch the input&lt;br /&gt; (*(*st1a-&gt;pvtable)[METHOD_GET])(st1a); // to get the data of object&lt;br /&gt; (*(*st2a-&gt;pvtable)[METHOD_GET])(st2a); // to get the data of object&lt;br /&gt;&lt;br /&gt; // using polymorphism&lt;br /&gt; gt1 = (struct general_type *)st1a;  /*  typecasting required */&lt;br /&gt; gt2 = (struct general_type *)st2a;  /*  typecasting required */&lt;br /&gt;&lt;br /&gt; s = push(s,gt1);&lt;br /&gt; s = push(s,gt2);&lt;br /&gt;&lt;br /&gt; /* similar working rule for other stack operations */&lt;br /&gt;&lt;br /&gt; gt1 = top_of_stack(s);&lt;br /&gt;&lt;br /&gt; (*(*gt1-&gt;pvtable)[METHOD_PRINT])(gt1); // to print the data of object&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xoxo&lt;br /&gt;aL&lt;br /&gt;&lt;/max_size_stack;&gt;</description><link>http://alinnovate.blogspot.com/2008/01/design-and-implementation-idea-of_12.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-779753264342978343</guid><pubDate>Sat, 12 Jan 2008 07:47:00 +0000</pubDate><atom:updated>2008-01-12T00:15:35.962-08:00</atom:updated><title>Design and Implementation Idea of POLYMORPHISM in C [ non - object oriented language] Part II</title><description>&lt;span style=&quot;font-weight: bold;&quot;&gt;Design Document&lt;/span&gt; -&lt;br /&gt;&lt;br /&gt;Here we are required to create a stack which can have element of different types.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Important notes&lt;/span&gt; -&lt;br /&gt;&lt;br /&gt;In order to apply Objected Oriented Programming concepts to C code, classes are mapped to structs and attributes to struct members and methods to function pointers.&lt;br /&gt;C language has the ability to store pointers for functions as a basic data type, and the ability to call a function from such a function pointer. We can associate with each instance (objects of structures) a table of functions. When a method call on a particular instance is executed, the function table for that instance (actually these tables are shared among the instances of a class), is used to find the proper function to execute.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Define objects&lt;/span&gt; –&lt;br /&gt;&lt;br /&gt;Here I have defined some Structures “general type”, “specific type 1”,” specific type 2”, etc. General type is like the super class from which other specific type classes are formed i.e. like sub classes. Each object has the appropriate data fields. Here is no type field associated with a structure and it is substituted by (at struct offset 0--the first field) with a vtable &quot;pointer to an array of pointers to functions returning int.&quot;&lt;br /&gt;&lt;br /&gt;There are only two functions associated with each object. Those are get () method and print () method. Get () is used to take input of the data fields of object and print is used for outputting those data fields.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Define vtables - actual polymorphism implementation &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.Virtual tables &quot;general type vtable&quot;, &quot;specific type 1 vtable&quot;, &quot;specific type 2 vtable&quot; and others are designed. Since there are no defined methods on General type object, that vtable is empty. I have just put a null pointer in the table.&lt;br /&gt;&lt;br /&gt;2.The various constructors *_ctor() methods of objects are implemented such that they set the vtable pointer of the appropriate object.&lt;br /&gt;&lt;br /&gt;3.#define constants are set up to identify offsets within the vtables. For example, the get() method will always be first in &quot;specific type 1 vtable&quot;, &quot;specific type 2 vtable&quot; and others since it is the first (and only) method in those objects.&lt;br /&gt;a.Example : #define METHOD_GET  0&lt;br /&gt;&lt;br /&gt;4.The size of a class’s vtable is the maximum number of methods in its interface.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;The pattern for invoking a method is:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;(*(*object-&gt;vtable)[method-index])(object);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xoxo&lt;br /&gt;aL&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://alinnovate.blogspot.com/2008/01/design-and-implementation-idea-of_11.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-1767445727809108558</guid><pubDate>Sat, 12 Jan 2008 07:37:00 +0000</pubDate><atom:updated>2008-01-11T23:48:41.309-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">object oriented implementation</category><category domain="http://www.blogger.com/atom/ns#">object oriented system implementation</category><category domain="http://www.blogger.com/atom/ns#">OOSI</category><category domain="http://www.blogger.com/atom/ns#">polumorphism</category><title>Design and Implementation Idea of POLYMORPHISM in C [ non - object oriented language] Part I</title><description>Here we were required to design a &lt;span style=&quot;font-weight: bold;&quot;&gt;polymorphic container&lt;/span&gt; (say, a stack) using the features provided by a procedural/modular programming language supporting ADT implementation. (Do not use polymorphic features of the language, and do not use a kind of tag i.e. any sort of type field).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Design document and Implementation provided in subsequent posts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xoxo&lt;br /&gt;aL</description><link>http://alinnovate.blogspot.com/2008/01/design-and-implementation-idea-of.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-3412226164218035979</guid><pubDate>Tue, 04 Dec 2007 08:46:00 +0000</pubDate><atom:updated>2007-12-04T02:02:17.302-08:00</atom:updated><title>Lehman Brothers FTA Technical and HR interview Experience</title><description>Technical (for about 50 min)&lt;br /&gt;&lt;br /&gt;It started with some &lt;span style=&quot;font-weight: bold;&quot;&gt;puzzles&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Given 7 gold bars connected with ropes, you have to give a labour  his payment for the day with one gold bar. You have to minimize the number of cuts (i.e. of ropes) so that you pay the labour for 7 days. He can never be under or over paid. &lt;2&gt;&lt;/li&gt;&lt;li&gt;The next was the 4 persons crossing the bridge who take different times (10s, 5s, 2s, 1s)... they have to carry  a lamp  .....  only  2 persons can travel the bridge at a time.  Optimize  the total time required. You may wanna propose a general strategy to deal with n people all with different times.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Project related questions.&lt;br /&gt;&lt;br /&gt;Internship related questions.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Computer Organization and Architecture&lt;/span&gt; related - how many functions did you implement in your 4 - bit CPU, name them. How many functions can be implemented, why the need for 0000 one. What is max bit size CPU available.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Cryptography&lt;/span&gt; - They asked about elliptic cryptography.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sorting &lt;/span&gt;Related&lt;br /&gt;&lt;br /&gt;Given two list of very large size (say 10 MB), how would you check that each element of one is present in the other. Start from the Brute force method, state its complexity. From here on start optimizing this check one step at a time, on the basis of Space and Time.&lt;br /&gt;&lt;br /&gt;Knowledge of Sorting methods, their complexities, when and where will they be used.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Link List&lt;/span&gt; related&lt;br /&gt;&lt;br /&gt;Reverse a single link list. Use minimum pointers. Do iteratively and also recursively, from front end and/or back end.&lt;br /&gt;&lt;br /&gt;Given a pointer to an intermediate node of a link list whose head pointer we do not have, how would you delete it.&lt;br /&gt;&lt;br /&gt;There were few other questions on linked list&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Binary Tree&lt;/span&gt; Related&lt;br /&gt;&lt;br /&gt;Questions related to tree heights , whats is the maximum and minimum height&lt;br /&gt;of the tree. Write Mathematical expression for the height.&lt;br /&gt;&lt;br /&gt;Write code to find the average height of the of the tree. Write code for finding maximum and minimum height of the tree.&lt;br /&gt;&lt;br /&gt;Asked about other Search algorithms, other than binary Search.&lt;br /&gt;&lt;br /&gt;There were some questions in between from other fields as well which I could no remember now. All these questions pretty much sums up the technical part.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Now the HR part .... (huff puff) &lt;/span&gt;(for about 20-25 min)&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Tell something about yourself.&lt;/li&gt;&lt;li&gt;Tell about your family.&lt;/li&gt;&lt;li&gt;Why not microsoft or google.&lt;/li&gt;&lt;li&gt;Why Mumbai when you can work in Bangalore where your brother is.&lt;/li&gt;&lt;li&gt;Where do you see yourself in 5 years.&lt;/li&gt;&lt;li&gt;Why not research.&lt;/li&gt;&lt;li&gt;What if you get a call from IIM A, B, C.&lt;/li&gt;&lt;li&gt;What if you get a call from IIM L, K, I.&lt;/li&gt;&lt;li&gt;Any Idea about firms like us (competitors).&lt;/li&gt;&lt;li&gt;What do you expect from the company.&lt;/li&gt;&lt;li&gt;How our Job profile different from others.&lt;/li&gt;&lt;li&gt;Hows our company different from others.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;There were other questions as well( i will post them when i remember ;-) ].&lt;br /&gt;&lt;br /&gt;xoxo&lt;br /&gt;aL&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;i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;</description><link>http://alinnovate.blogspot.com/2007/12/technical-for-about-50-min-it-started.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-2054154688442170282</guid><pubDate>Mon, 03 Dec 2007 04:42:00 +0000</pubDate><atom:updated>2007-12-02T20:44:46.494-08:00</atom:updated><title>How to display a percentage-done indication on the screen?</title><description>&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: rgb(255, 255, 255);font-size:130%;&quot; &gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;The character &#39;\r&#39; is a carriage return without the usual line feed, this helps to overwrite the current line. The character &#39;\b&#39; acts as a backspace, and will move the cursor one position to the left.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;XOXO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;aL&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;</description><link>http://alinnovate.blogspot.com/2007/12/how-to-display-percentage-done.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-2266259476071721647</guid><pubDate>Sun, 02 Dec 2007 18:00:00 +0000</pubDate><atom:updated>2007-12-02T10:01:52.372-08:00</atom:updated><title>Sudoku verifier using bit fields</title><description>&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; VerifySudoku(&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; grid[81])&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; bitFlags = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; buffer; &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-style: italic;&quot;&gt;// to speed up things&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; r, c;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; (r = 0; r &lt; bitflags =&quot; 0,&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; (c = 0; c &lt;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;           buffer = r/3*3+c/3;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color: rgb(255, 255, 204); font-style: italic;&quot;&gt;                     // check horizontally&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;     bitFlags |= 1 &lt;&lt; (27-grid[(r&lt;&lt;3)+r+c])&gt;&lt;br /&gt;  &lt;span style=&quot;color: rgb(255, 255, 204); font-style: italic;&quot;&gt;                     // check vertically&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;                    |   1 &lt;&lt; (18-grid[(c&lt;&lt;3)+c+r])&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-style: italic;&quot;&gt;&lt;br /&gt;                      // check subgrids&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;                  |   1 &lt;&lt; (9-grid[(buffer&lt;&lt;3)+buffer+r%3*3+c%3]);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; (bitFlags != 0x7ffffff)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;         &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; 0;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204); font-weight: bold;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt; 1;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 204);&quot;&gt;  }&lt;/span&gt;</description><link>http://alinnovate.blogspot.com/2007/12/sudoku-verifier-using-bit-fields.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-5760610129491626392</guid><pubDate>Sun, 02 Dec 2007 17:42:00 +0000</pubDate><atom:updated>2007-12-02T09:43:23.648-08:00</atom:updated><title>Dutch National Flag Algorithm, or 3-way Partitioning</title><description>&lt;p&gt;The problem was posed with three colours, here `0&#39;, `1&#39; and `2&#39;. The array is divided into four sections: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;a[1..Lo-1] zeroes (red)&lt;/li&gt;&lt;li&gt;a[Lo..Mid-] ones (white)&lt;/li&gt;&lt;li&gt;a[Mid..Hi] unknown&lt;/li&gt;&lt;li&gt;a[Hi+1..N] twos (blue)&lt;/li&gt;&lt;/ol&gt; The unknown region is shrunk while maintaining these conditions     &lt;ol&gt;&lt;li&gt;Lo := 1; Mid := 1; Hi := N;&lt;/li&gt;&lt;li&gt;while Mid &lt;= Hi do   &lt;ol&gt;&lt;li&gt;Invariant: a[1..Lo-1]=0 and a[Lo..Mid-1]=1 and a[Hi+1..N]=2;       &lt;nobr&gt;a[Mid..Hi] are unknown.&lt;/nobr&gt;&lt;/li&gt;&lt;li&gt;case a[Mid] in   &lt;ul&gt;&lt;li&gt;0: swap a[Lo] and a[Mid]; Lo++; Mid++&lt;/li&gt;&lt;li&gt;1: Mid++&lt;/li&gt;&lt;li&gt;2: swap a[Mid] and a[Hi]; Hi--&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;XOXO&lt;br /&gt;aL</description><link>http://alinnovate.blogspot.com/2007/12/dutch-national-flag-algorithm-or-3-way.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-3789733879609836389</guid><pubDate>Wed, 26 Sep 2007 05:05:00 +0000</pubDate><atom:updated>2007-09-25T22:06:32.521-07:00</atom:updated><title>Optimizing C and C++ Code</title><description>Optimizing C and C++ Code&lt;br /&gt;&lt;br /&gt;Embedded software often runs on processors with limited computation power, thus optimizing the code becomes a necessity. In this article we will explore the following optimization techniques for C and C++ code developed for Real-time and Embedded Systems.&lt;br /&gt;&lt;br /&gt;1. Adjust structure sizes to power of two&lt;br /&gt;2. Place case labels in narrow range&lt;br /&gt;3. Place frequent case labels first&lt;br /&gt;4. Break big switch statements into nested switches&lt;br /&gt;5. Minimize local variables&lt;br /&gt;6. Declare local variables in the inner most scope&lt;br /&gt;7. Reduce the number of parameters&lt;br /&gt;8. Use references for parameter passing and return value for types bigger than 4 bytes&lt;br /&gt;9. Don&#39;t define a return value if not used&lt;br /&gt;10. Consider locality of reference for code and data&lt;br /&gt;11. Prefer int over char and short&lt;br /&gt;12. Define lightweight constructors&lt;br /&gt;13. Prefer initialization over assignment&lt;br /&gt;14. Use constructor initialization lists&lt;br /&gt;15. Do not declare &quot;just in case&quot; virtual functions&lt;br /&gt;16. In-line 1 to 3 line functions&lt;br /&gt;&lt;br /&gt;Al&lt;br /&gt;&lt;br /&gt;read more @ &lt;a href=&quot;http://www.eventhelix.com/RealtimeMantra/Basics/OptimizingCAndCPPCode.htm#Place%20Frequent%20Case%20Labels%20First&quot;&gt;http://www.eventhelix.com/RealtimeMantra/Basics/OptimizingCAndCPPCode.htm#Place%20Frequent%20Case%20Labels%20First&lt;/a&gt;</description><link>http://alinnovate.blogspot.com/2007/09/optimizing-c-and-c-code.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-8227710133741081663</guid><pubDate>Wed, 05 Sep 2007 19:44:00 +0000</pubDate><atom:updated>2007-09-05T13:06:07.744-07:00</atom:updated><title>Programming puzzles ... dare to solve</title><description>Programming puzzles ..... these are quite boring for the masters and experts , neways have a look at it ... i guess it will be fun for new experts .... and posts the answers as comments without checking out provided forum post.&lt;br /&gt;&lt;br /&gt;Q1 Write a &quot;Hello World&quot; program in &#39;C&#39; without using a semicolon.&lt;br /&gt;Q2 Write a C++ program without using any loop (if, for, while etc) to&lt;br /&gt;print numbers from 1 to 100 and 100 to 1;&lt;br /&gt;Q3 C/C++ : Exchange two numbers without using a temporary variable.&lt;br /&gt;Q4 C/C++ : Find if the given number is a power of 2.&lt;br /&gt;Q5 C/C++ : Multiply x by 7 without using multiplication (*) operator.&lt;br /&gt;Q6 C/C++ : Write a function in different ways that will return f(7) =&lt;br /&gt;4 and f(4) = 7&lt;br /&gt;Q7 Remove duplicates in array&lt;br /&gt;Q8 Finding if there is any loop inside linked list.&lt;br /&gt;Q9 Remove duplicates in an no key access database without using an&lt;br /&gt;array&lt;br /&gt;Q10 Write a program whose printed output is an exact copy of the&lt;br /&gt;source. Needless to say, merely echoing the actual source file is not&lt;br /&gt;allowed.&lt;br /&gt;Q11 From a &#39;pool&#39; of numbers (four &#39;1&#39;s, four &#39;2&#39;s .... four &#39;6&#39;s),&lt;br /&gt;each player selects a number and adds it to the total. Once a number&lt;br /&gt;is used, it must be removed from the pool. The winner is the person&lt;br /&gt;whose number makes the total equal 31 exactly.&lt;br /&gt;Q12 Swap two numbers without using a third variable.&lt;br /&gt;Given an array (group) of numbers write all the possible sub groups of&lt;br /&gt;this group.&lt;br /&gt;Q14 Convert (integer) number in binary without loops.&lt;br /&gt;&lt;br /&gt;Al&lt;br /&gt;&lt;a href=&quot;http://www.thescripts.com/forum/thread217806.html&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.praveen.ws/journal/2006/09/04/c-and-c-puzzles/&quot;&gt;http://www.praveen.ws/journal/2006/09/04/c-and-c-puzzles/&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2004-06/2652.html&quot;&gt;http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2004-06/2652.html&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.velocityreviews.com/forums/t284024-programming-puzzle.html&quot;&gt;http://www.velocityreviews.com/forums/t284024-programming-puzzle.html&lt;/a&gt;</description><link>http://alinnovate.blogspot.com/2007/09/programming-puzzles-dare-to-solve.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-2127464630131123458</guid><pubDate>Wed, 05 Sep 2007 19:18:00 +0000</pubDate><atom:updated>2007-09-05T12:31:59.188-07:00</atom:updated><title>without semicolon how to write c program</title><description>How to print something - say to write a code &quot;hello world&quot; without any semicolon.&lt;br /&gt;Well the solution is very simple...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;b&gt;&lt;br /&gt;#include &amp;lt stdio.h &amp;gt&lt;br /&gt;main() {  if (printf(&quot;Hello, world!&quot;)) {} }&lt;br /&gt;&lt;br /&gt;&lt;/b&gt; Al  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;js-kit-rating&quot; path=&quot;/rate/0046592007&quot; view=&quot;split&quot;&gt;&lt;/div&gt;</description><link>http://alinnovate.blogspot.com/2007/09/without-semicolon-how-to-write-c.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-3179904594830277558</guid><pubDate>Mon, 03 Sep 2007 15:58:00 +0000</pubDate><atom:updated>2007-09-03T08:59:58.660-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">getclass</category><category domain="http://www.blogger.com/atom/ns#">instanceof</category><category domain="http://www.blogger.com/atom/ns#">java</category><title>.getClass() vs instanceof</title><description>&lt;pre&gt;&lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;class&lt;/b&gt;&lt;/span&gt; Parent &lt;span style=&quot;color:navy;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:navy;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;class&lt;/b&gt;&lt;/span&gt; Child &lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;extends&lt;/b&gt;&lt;/span&gt; Parent &lt;span style=&quot;color:navy;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:navy;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Child c = &lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt; Child();&lt;br /&gt;&lt;br /&gt;c &lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;instanceof&lt;/b&gt;&lt;/span&gt; Parent is &lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;c.getClass().equals(Parent.class) is &lt;span style=&quot;color:navy;&quot;&gt;&lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;bye&lt;br /&gt;Al (alokadvin)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div class=&quot;js-kit-rating&quot; path=&quot;/rate/2124392007&quot; view=&quot;split&quot;&gt;&lt;/div&gt;</description><link>http://alinnovate.blogspot.com/2007/09/getclass-vs-instanceof.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-4677877428272532410</guid><pubDate>Mon, 03 Sep 2007 08:40:00 +0000</pubDate><atom:updated>2007-09-03T06:39:59.907-07:00</atom:updated><title>mypictr - we make your profile picture</title><description>Hey ,&lt;br /&gt;find a cool way to edit your pictures on-line&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://mypictr.com/?size=50x50#syp&quot;&gt;mypictr - we make your profile picture&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Al&lt;br /&gt;&lt;div class=&quot;js-kit-rating&quot; path=&quot;/rate/1340392007&quot; view=&quot;split&quot;&gt;&lt;/div&gt;</description><link>http://alinnovate.blogspot.com/2007/09/mypictr-we-make-your-profile-picture.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-150832609310009919</guid><pubDate>Sun, 02 Sep 2007 08:05:00 +0000</pubDate><atom:updated>2007-09-03T06:42:07.982-07:00</atom:updated><title>Affine Cipher Deciphered</title><description>Hi&lt;br /&gt;&lt;br /&gt;Aﬃne Ciphers -&lt;br /&gt;An encipherment scheme (or algorithm) of the form&lt;br /&gt;                                      E (x) = (ax + b) MOD 26&lt;br /&gt;is called an aﬃne cipher. Here x is the numerical equivalent of the given plaintext letter, and a and&lt;br /&gt;b are (appropriately chosen) integers.&lt;br /&gt;&lt;br /&gt;What are the possible values for which one to one ciphers are possible...&lt;br /&gt;i.e if p and q are two plaintext such that p ne q then E(k,p) ne E(k,q).&lt;br /&gt;&lt;br /&gt;The function E (x) = (ax + b) MOD 26 deﬁnes a valid aﬃne cipher if a is relatively prime to 26, and b&lt;br /&gt;is an integer between 0 and 25, inclusive. If b = 0, then we refer to this cipher as a decimation cipher.&lt;br /&gt;(Note that since there are 12 valid choices of a and 26 valid choices of b, there are 12 × 26 = 312 possible&lt;br /&gt;valid aﬃne ciphers.)&lt;br /&gt;Also note that if a = 1, then E (x) = (x + b) MOD 26 is simply a Caesar (+b) shift cipher.&lt;br /&gt;&lt;br /&gt;Do more with affine cipher @ &lt;a href=&quot;http://home.clara.net/paulwlocke/portfolio/affine.html&quot;&gt;http://home.clara.net/paulwlocke/portfolio/affine.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;bye&lt;br /&gt;&lt;div class=&quot;js-kit-rating&quot; path=&quot;/rate/1340292007&quot; view=&quot;split&quot;&gt;&lt;/div&gt;</description><link>http://alinnovate.blogspot.com/2007/09/affine-cipher-deciphered.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-9206950845896554173</guid><pubDate>Sun, 26 Aug 2007 18:28:00 +0000</pubDate><atom:updated>2007-09-03T06:43:33.642-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C</category><category domain="http://www.blogger.com/atom/ns#">pointers</category><category domain="http://www.blogger.com/atom/ns#">polymorphism</category><title>polymorphism in C</title><description>Even polymorphism can by implemented in C. Polymorphism in Java and C++ is implemented by associating with each instance a table of functions.  Polymorphic method names are converted to indexes into this function table. When a method call on a particular instance is executed, the function table for that instance (actually these tables are shared among the  instances of a class), used to find the proper function to execute. &lt;p&gt; Since C has the ability to store pointers for functions as a basic data type, and the ability to calla function from such a function pointer. It is straightforward (though not always fun) to explicitly duplicate the function table mechanism and implement polymorphisms by hand.&lt;br /&gt;&lt;/p&gt;Al&lt;br /&gt;&lt;div class=&quot;js-kit-rating&quot; path=&quot;/rate/1240292007&quot; view=&quot;split&quot;&gt;&lt;/div&gt;</description><link>http://alinnovate.blogspot.com/2007/08/polymorphism-in-c.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-6692069376999901464</guid><pubDate>Sun, 26 Aug 2007 14:10:00 +0000</pubDate><atom:updated>2007-09-03T06:44:48.950-07:00</atom:updated><title>How to read C declarators  PART 2</title><description>&lt;h4&gt;Function pointers and combinations&lt;/h4&gt;   &lt;p&gt;The C &quot;forward&quot; declaration:  &lt;/p&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre&gt; 1.) extern int foo();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;p&gt;just says that &lt;em&gt;foo is a function returning int&lt;/em&gt;.  This follows the same pattern for reading declarators as you saw in previous post. Start at &lt;tt&gt;foo&lt;/tt&gt; and look right.  You see &lt;tt&gt;()&lt;/tt&gt; so say &lt;em&gt;function&lt;/em&gt;.  You look left and see &lt;tt&gt;int&lt;/tt&gt;.  Say &lt;em&gt;int&lt;/em&gt;.  &lt;/p&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;font-family:Georgia,serif;&quot;&gt;        2.) &lt;/span&gt;extern int *foo();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;p&gt;Yep, you say &lt;em&gt;foo is a function returning a pointer to int&lt;/em&gt;.  &lt;/p&gt;&lt;p&gt;Now for the big leap.  Just like we can make a pointer to an &lt;tt&gt;int&lt;/tt&gt; or whatever, let&#39;s make a pointer to a function.  In this case, we can drop the &lt;tt&gt;extern&lt;/tt&gt; as it&#39;s no longer a function forward reference, but a data variable declaration.  Here is the basic pattern for function pointer:  &lt;/p&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre&gt; 3.) int (*foo)();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;p&gt;You start at &lt;tt&gt;foo&lt;/tt&gt; and see nothing to the right.  So, to the left, you say &lt;em&gt;pointer&lt;/em&gt;.  Then to the right outside you see &lt;em&gt;function&lt;/em&gt;.  Then left you see &lt;tt&gt;int&lt;/tt&gt;.  So you say &lt;em&gt;foo is a pointer to a function returning int&lt;/em&gt;.  &lt;/p&gt;&lt;p&gt;Here is &lt;em&gt;an array of pointers to functions returning int&lt;/em&gt;:  &lt;/p&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre&gt; 4.) int (*Object_vtable[])();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;p&gt;One last, incredibly bizarre declaration, for fun:  &lt;/p&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre&gt; 5.) int (*(*vtable)[])();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;p&gt;This pointer to a vtable is set to the address of a vtable.   &lt;/p&gt;&lt;p&gt;In summary:  &lt;/p&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre&gt; int *ptr_to_int;&lt;br /&gt;int *func_returning_ptr_to_int();&lt;br /&gt;int (*ptr_to_func_returning_int)();&lt;br /&gt;int (*array_of_ptr_to_func_returning_int[])();&lt;br /&gt;int (*(*ptr_to_an_array_of_ptr_to_func_returning_int)[])();&lt;br /&gt;&lt;br /&gt;regards&lt;br /&gt;Al&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;js-kit-rating&quot; path=&quot;/rate/1140292007&quot; view=&quot;split&quot;&gt;&lt;/div&gt;</description><link>http://alinnovate.blogspot.com/2007/08/how-to-read-c-declarators-part-2.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-4186047228629026274</guid><pubDate>Sun, 26 Aug 2007 14:09:00 +0000</pubDate><atom:updated>2007-08-26T07:09:53.883-07:00</atom:updated><title>How to read C declarators  PART 1</title><description>Reading C declarators in a precise manner.&lt;br /&gt;&lt;br /&gt;The rule goes like this:&lt;br /&gt;&lt;br /&gt;   &quot;Start at the variable name (or innermost construct if no identifier is present. Look right without jumping over a right parenthesis; say what you see. Look left again without jumping over a parenthesis; say what you see. Jump out a level of parentheses if any. Look right; say what you see. Look left; say what you see. Continue in this manner until you say the variable type or return type.&quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The degenerate case is:&lt;br /&gt;&lt;br /&gt;int i;&lt;br /&gt;&lt;br /&gt;Starting at i, you look right and find nothing. You look left and find the type int, which you say. Done.&lt;br /&gt;&lt;br /&gt;Ok, now a more complicated one:&lt;br /&gt;&lt;br /&gt;int *a[3];&lt;br /&gt;&lt;br /&gt;Start at a. Look right, say array of size 3. Look left and say pointer. Look right and see nothing. Look left and say int. All together you say a is an array of size 3 pointers to int.&lt;br /&gt;&lt;br /&gt;Adding parentheses is when it gets weird:&lt;br /&gt;&lt;br /&gt;int (*a)[3];&lt;br /&gt;&lt;br /&gt;The parentheses change the order just like in an expression. When you look right after a, you see the right parenthesis, which you cannot jump over until you look left. Hence, you would say a is a pointer to an array of 3 ints.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;bye for now&lt;br /&gt;Al</description><link>http://alinnovate.blogspot.com/2007/08/how-to-read-c-declarators-part-1.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-6075652345714043703</guid><pubDate>Fri, 24 Aug 2007 19:39:00 +0000</pubDate><atom:updated>2008-09-21T05:54:30.290-07:00</atom:updated><title>Object oriented modelling in C - PART 3 - Inheritance</title><description>&lt;p&gt;&lt;span style=&quot;font-family:verdana, georgia, sans-serif;font-size:85%;&quot;&gt;Inheritance is a mechanism by which new and more specialized classes can be defined in terms of existing classes. When a child class (subclass) inherits from a parent class (superclass), the subclass then includes the definitions of all the attributes and methods that the superclass defines. Usually, the subclass extends the superclass by adding its own attributes and methods. Objects that are instances of the subclass contain all data defined by the subclass and its parent classes, and they are able to perform all operations defined by this subclass and its parents. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:verdana, georgia, sans-serif;font-size:85%;&quot;&gt;This kind of class relationship can be implemented in C by embedding the parent class attribute structure as the first member of the child class structure. This structuring results in such an attribute alignment that a pointer to the Child class can always be safely cast (upcast) on the pointer to the Parent class. In particular, this pointer can always be passed to any C function expecting a pointer to the Parent class. (To be strictly correct in C, you should explicitly upcast this pointer.) This means that all methods of parent classes are automatically available to child classes-in other words, they are inherited. &lt;/span&gt;&lt;/p&gt;</description><link>http://alinnovate.blogspot.com/2007/08/object-oriented-modelling-in-c-part-3.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-8163750362014781807</guid><pubDate>Fri, 24 Aug 2007 19:37:00 +0000</pubDate><atom:updated>2007-08-24T12:38:46.839-07:00</atom:updated><title>Object oriented modelling in C - PART 2 - Encapsulation</title><description>&lt;p&gt;&lt;span style=&quot;font-family:verdana, georgia, sans-serif;font-size:85%;&quot;&gt;You can achieve packaging of data with functions in C by making each class attribute (instance variable) a field in the C struct. You implement class methods as C functions that take as their first argument the pointer to the structure of attributes (the this pointer). You can further strengthen the association between the attributes and methods by a consistent naming convention for method names. The most popular convention that I adopt is to concatenate the structure name (class name) with the operation name. This altering of function names is part of name decorating (also known as name mangling) and is performed implicitly by most C++ compilers. Because name decorating eliminates method name clashes between different classes, it effectively partitions the flat C function namespace into separate namespaces nested within classes. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:verdana, georgia, sans-serif;font-size:85%;&quot;&gt;The next aspect I address by a coding convention is access control. In C, you can only indicate your intention for the level of access permitted to a particular attribute or a method. Conveying this intention through the name of an attribute or a method is better than just expressing it in the form of a comment at the declaration point. In this way, unintentional access to class members in any portion of the code will be easier to detect. Most OO designs distinguish the following three levels of protection: &lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;span style=&quot;font-family:verdana, georgia, sans-serif;font-size:85%;&quot;&gt;&lt;li&gt;private-accessible only from within the class &lt;/li&gt;&lt;li&gt;protected-accessible only by the class and its subclasses &lt;/li&gt;&lt;li&gt;public-available anywhere (de-fault in C) &lt;/li&gt;&lt;/span&gt;&lt;/ul&gt;&lt;span style=&quot;font-family:verdana, georgia, sans-serif;font-size:85%;&quot;&gt;Optionally, a class may provide a destructor, which is a method responsible for releasing the resources allocated during the lifetime of an object. Whereas there may be many ways of instantating a class (different constructors taking different arguments), there should be only one way of destroying an object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://alinnovate.blogspot.com/2007/08/object-oriented-modelling-in-c-part-2.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-8354229714144510673</guid><pubDate>Fri, 24 Aug 2007 19:36:00 +0000</pubDate><atom:updated>2007-08-24T12:36:35.789-07:00</atom:updated><title>Object oriented modelling in C - PART 1</title><description>&lt;a href=&quot;http://www.embedded.com/97/fe29712.htm&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;span style=&quot;;font-family:verdana,georgia,sans-serif;font-size:85%;&quot;  &gt;In spite of unquestioned advantages of OO languages, C still remains the best known and widespread implementation language. Most developers still exclusively use procedural programming techniques, and many are unaware that it&#39;s quite easy to implement key OO concepts directly in C. Promoting this awareness may be important for at least two reasons. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;;font-family:verdana,georgia,sans-serif;font-size:85%;&quot;  &gt;The first is leveraging OO technology. Most OO designs can be implemented in C, but many developers wouldn&#39;t consider them without the availability of an OO language. This unnecessarily limits application of the technology. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;;font-family:verdana,georgia,sans-serif;font-size:85%;&quot;  &gt;The second is smoothing transition from procedural to OO thinking. Migrating to OO technology can require quite a leap in your way of thinking. Implementing OO concepts in currently used and familiar languages gives you an opportunity to get exposed to the new programming paradigm right away and without major investment.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;;font-family:verdana,georgia,sans-serif;font-size:85%;&quot;  &gt;Al&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://alinnovate.blogspot.com/2007/08/object-oriented-modelling-in-c-part-1.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-1723326273426783627</guid><pubDate>Fri, 17 Aug 2007 12:03:00 +0000</pubDate><atom:updated>2007-08-17T05:05:22.001-07:00</atom:updated><title>Download video from youtube</title><description>It&#39;s strange that none of the video sharing sites provide a simple one-click button to download videos. So we will have to take the help of easy workarounds to download the videos. Here are three different ways to download any video from the internet though internally, they employ the same hack (Right-click -&gt; &quot;Save Target As&quot; OR copy the link into your download manager. but change the file extension to .flv)&lt;br /&gt;&lt;br /&gt;Approach 1: The easiest way is to copy your video URL and paste it on &lt;a href=&quot;http://keepvid.com/lite/&quot; target=&quot;_blank&quot;&gt;KeepVid Lite&lt;/a&gt;. When you click submit, you will be provided with a link to save the video as an FLV file.&lt;br /&gt;&lt;br /&gt;Approach 2: &lt;a href=&quot;javascript:document.location=&#39;http://keepvid.com/?url=&#39;+escape(window.location);&quot;&gt;Bookmark this Link&lt;/a&gt; or drag it your browser links toolbar. When you want to download a certain video, open the link in your browser and click the KeepVid button.&lt;br /&gt;&lt;br /&gt;Approach 3: For Firefox Users - Install the &lt;a href=&quot;https://addons.mozilla.org/firefox/2390/&quot; target=&quot;_blank&quot;&gt;VideoDownloader Extension&lt;/a&gt; from Mozilla Addons website - It downloads all embedded objects on a webpage including the video clips.&lt;br /&gt;&lt;br /&gt;read more on&lt;br /&gt; &lt;a href=&quot;http://labnol.blogspot.com/2006/07/10-interesting-things-you-can-do-with.html&quot;&gt;http://labnol.blogspot.com/2006/07/10-interesting-things-you-can-do-with.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;bye</description><link>http://alinnovate.blogspot.com/2007/08/download-video-from-youtube.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-3834703819232878061</guid><pubDate>Thu, 16 Aug 2007 08:49:00 +0000</pubDate><atom:updated>2007-08-16T02:10:14.966-07:00</atom:updated><title>Embed Audio Files in HTML pages</title><description>&lt;span style=&quot;color: rgb(102, 255, 153);font-family:arial;font-size:100%;&quot;  &gt;&lt;span style=&quot;color: rgb(255, 255, 255);&quot;&gt;To add the wav file to your html page use the        following:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 128);font-family:arial;font-size:130%;&quot;  &gt;#EMBED src=&quot;file.wav&quot; autostart=true loop=false        volume=100&lt;br /&gt;hidden=true@#NOEMBED@#BGSOUND        src=&quot;file.wav&quot;#/NOEMBED@&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 255);font-family:arial;font-size:100%;&quot;  &gt;&lt;br /&gt;&lt;span style=&quot;font-size:78%;&quot;&gt;replace - @ with &gt;&lt;br /&gt;replace - # with &lt;  &lt;/span&gt;Where the a file named file .wav        has been uploaded to your site in the same directory as the page which        contains the EMBED tags.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 128);font-family:arial;font-size:100%;&quot;  &gt;&lt;span style=&quot;color: rgb(255, 255, 255);&quot;&gt;In the above example where autostart=true, the file will        automatically start playing. Use this tag for background sound which        should start immediately once it is downloaded.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 255);&quot;&gt;You can also use        loop=true where you want the sound to repeat over and over. By editing a        short sound and using the loop=true option you can create continuous audio        from a very short audio cut. For example: waves, applause, engine sounds        and so on.&lt;br /&gt;&lt;br /&gt;get more on&lt;br /&gt;&lt;a href=&quot;http://www.tips-tricks.com/sound.asp&quot;&gt;http://www.tips-tricks.com/sound.asp&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 255);&quot;&gt;bye&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 255, 255);&quot;&gt;AL&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://alinnovate.blogspot.com/2007/08/embed-audio-files-in-html-pages.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5846472446395912215.post-3594565015817146142</guid><pubDate>Thu, 16 Aug 2007 08:25:00 +0000</pubDate><atom:updated>2007-08-16T01:38:26.118-07:00</atom:updated><title>Basic Information About Sound Files</title><description>&lt;span style=&quot;font-family:comic sans ms;&quot;&gt;So start with some audio formats, which might be helpful in adding audio features in my web pages.&lt;br /&gt;&lt;br /&gt;The two most widely supported file formats for sound files are MIDI and WAV. As with graphic files, you&#39;ll want to keep the size of the file as small as possible while maintaining quality.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:comic sans ms;&quot;&gt;The differences between WAV and MIDI are that MIDI files are generally a great deal smaller, however, many types of audio, such as speech, don&#39;t work well as MIDI files. MIDI is a good file format for music. A one minute WAV file can be as large as 1MB in size, while a 1 minute MIDI file can be less than 25K. Using software convertors, it may be possible to resample WAV files to reduce their file size.&lt;br /&gt;&lt;br /&gt;Some helpful and interesting links are -&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-family:comic sans ms;&quot;&gt;&lt;a href=&quot;http://www.wavplace.com/&quot;&gt;The Wav Place &lt;/a&gt;- offers movie audio clips, cartoon sounds, and music files&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.midiweb.com/&quot;&gt;MidiWeb&lt;/a&gt; - offers technical information about MIDI files and MIDI interfaces, a library of download able MIDI files.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.filecity.com/midi/&quot;&gt;FileCity&lt;/a&gt; offers a huge archive of MIDI files, including movie theme songs, rock music, holiday songs, and more.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.midifarm.com/&quot;&gt;MidiFarm&lt;/a&gt;also offers a library of downloadable MIDI files. &lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.wavcentral.com/&quot;&gt;WavCentral&lt;/a&gt; offers a huge archive of audio files that you can download.&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.moviewavs.com/&quot;&gt;MovieWavs &lt;/a&gt;offers...you guessed it! Wav files from popular films. &lt;/li&gt;&lt;/ol&gt;bye for now&lt;br /&gt;AL</description><link>http://alinnovate.blogspot.com/2007/08/basic-information-about-sound-files.html</link><author>noreply@blogger.com (alokadvin)</author><thr:total>0</thr:total></item></channel></rss>