C,C++/JAVA/BASH/ASM ARENA

वह प्रदीप जो दीख रहा है झिलमिल दूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है चिन्गारी बन गयी लहू की बून्द गिरी जो पग से चमक रहे पीछे मुड देखो चरण-चिनह जगमग से बाकी होश तभी तक, जब तक जलता तूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है अपनी हड्डी की मशाल से हृदय चीरते तम का, सारी रात चले तुम दुख झेलते कुलिश का। एक खेय है शेष, किसी विध पार उसे कर जाओ; वह देखो, उस पार चमकता है मन्दिर प्रियतम का। आकर इतना पास फिरे, वह सच्चा शूर नहीं है; थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है। दिशा दीप्त हो उठी प्राप्त कर पुण्य-प्रकाश तुम्हारा, लिखा जा चुका अनल-अक्षरों में इतिहास तुम्हारा। जिस मिट्टी ने लहू पिया, वह फूल खिलाएगी ही, अम्बर पर घन बन छाएगा ही उच्छ्वास तुम्हारा। और अधिक ले जाँच, देवता इतन क्रूर नहीं है। थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है।

Static Scoping vs Dynamic Scoping November 26, 2013

Filed under: C,C++ Programs,Coding,Compiler — whoami @ 12:33

Many C programmers might not have heard the term ‘Static Scoping’ and ‘Dynamic Scoping’. Since C only supports Static Scoping. Static Scoping is also called Lexical/Text Scoping.

Read the following article to understand what these two scoping mean in Computer Science.

1.  Article 1

2. Article 2

3. Article 3

The above things might confuse since this dynamic scoping is not supported in many languages including C and hence you might not be able to test the same. But the point is to understand it. What Dynamic Scoping means.

 

 

 

 

Advertisements
 

Got amazed by the exppression &(((struct st *) 0) ->member_st). But finally found this is valid and C has similar implementation for ‘offsetof’ September 16, 2013

Filed under: C,C Library,C++ Programs,Coding,Compiler,Computers — whoami @ 20:23

Some day back i was going through some library code in C and found expression like

 &(((some_struct_type *) 0) -> some_element_of_some_struct_type);

And started wondering what will happen to access an element located at NULL. Thought something is wrong with the code then one of my senior suggested suggested this is Ok and then found lot of information on the web. Also the same feature is available in C as MACRO offsetof.

1. Stackoverflow

2. Stackoverflow

3. C wiki

4. C examples

 

Conclusion:

* The expression ((some_struct_type *) 0) -> some_element_of_some_struct_type is invalid/undefined because we are trying to access element of some structure which is not correctly located at defined address. But the expression prefix with & becomes valid because the whole expression of getting address of member element of struct (assumed to be located at NULL) is calculated at compile time and hence dereferencing is avoided.

 

 

nfa to dfa conversion best explained July 26, 2010

Filed under: C,C++ Programs,Compiler — whoami @ 16:29
Tags: ,

Here is the example from ullman sethi

link

other links of programs

 

Finding First{},and Follow{} -Compiler February 12, 2010

Filed under: Compiler — whoami @ 22:14

(more…)