Hey guys If anyone attended amazon interview could you please let me know the pattern of interview and also if you remember few question.
Thanks inadvance. Sent from my iPhone On Feb 27, 2011, at 5:07, gaurav gupta <[email protected]> wrote: > I guess macro can be a work arround for this. > > in configuration you can provide files which can access a global variable > ProtectedVariable > > you have defined PROTECTEDVARIABLE_ACCESSIBLE_IN_FILEONE > like > > global.c > > int ProtectedVariable = 10; > /* > other stuff > */ > > fileone.c > > #ifdef PROTECTEDVARIABLE_ACCESSIBLE_IN_FILEONE > > extern int ProtectedVariable > #elseif > static int ProtectedVariable; > #endif > > /* > some stuff which can access ProtectedVariable > */ > > filetwo.c > > #ifdef PROTECTEDVARIABLE_ACCESSIBLE_IN_FILETWO > extern int ProtectedVariable; > #elseif > static int ProtectedVariable; > #endif > > > /* > some stuff which try to access ProtectedVariable but it wont be able to > acess global one, it will access the local ProtectedVariable . > > */ > > So fileone can access global variable but filetwo not, I guess this was asked > by Jalaj? > > On Fri, Feb 25, 2011 at 5:11 PM, Arulanandan P <[email protected]> wrote: > > @jalaj guys please understand how the static and extern work first. > > static makes the variables or functions defined in an object file to be > > local to that object file. > > When you declare the variable or function as extern , it means that > > definition is present in some other object file and it will be resolved at > > the link time only. > > By default all the global variables and functions are visible to other > > object files. > > Example: > > a.c > > === > > int var = 10; // global variable so accessible to other files. > > static void func() // static - so not accessible to other files > > { > > } > > > > b.c > > === > > extern int var ; > > main() > > { > > var = 20 ; > > func() ; // this is not permitted since the func() is declared as > > static > > } > > > > > > This is how the compilation works: > > gcc -c -o a.o a.c > > gcc -c -o b.o b.c > > > > gcc -o exe b.o a.o > > // This will lead to linker error since func is declared static. > > > > Regards > > Arul > > On Fri, Feb 25, 2011 at 12:00 AM, nishaanth <[email protected]> wrote: > >> > >> Declare it as static. > >> > >> On Wed, Feb 23, 2011 at 11:33 PM, Jammy <[email protected]> wrote: > >>> > >>> Are you talking about IPC? > >>> > >>> On Feb 22, 10:05 am, jaladhi dave <[email protected]> wrote: > >>> > What do you mean by data element here ? Also by file you mean the file > >>> > where > >>> > you wrote the code ? And above all which programming language are we > >>> > talking > >>> > ? > >>> > > >>> > You hit send button too early I guess :) > >>> > > >>> > On 22-Feb-2011 7:39 PM, "jalaj jaiswal" <[email protected]> > >>> > wrote: > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > Is there any way by which a data element in a file is accessible by > >>> > another > >>> > > file, where the program has multiple files. That data element should > >>> > > be > >>> > > accessible to a particular file only and inaccessible to the rest.? > >>> > > >>> > > declaring it as an extern will make it accessible to all i think .. > >>> > > what > >>> > cud > >>> > > be the answer ? > >>> > > >>> > > -- > >>> > > With Regards, > >>> > > *Jalaj Jaiswal* (+919019947895) > >>> > > Software developer, Cisco Systems > >>> > > B.Tech IIIT ALLAHABAD > >>> > > >>> > > -- > >>> > > You received this message because you are subscribed to the Google > >>> > > Groups > >>> > > >>> > "Algorithm Geeks" group.> To post to this group, send email to > >>> > [email protected]. > >>> > > To unsubscribe from this group, send email to > >>> > > >>> > [email protected].> For more options, visit this > >>> > group at > >>> > > >>> > http://groups.google.com/group/algogeeks?hl=en. > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "Algorithm Geeks" group. > >>> To post to this group, send email to [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]. > >>> For more options, visit this group at > >>> http://groups.google.com/group/algogeeks?hl=en. > >>> > >> > >> > >> > >> -- > >> S.Nishaanth, > >> Computer Science and engineering, > >> IIT Madras. > >> > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Algorithm Geeks" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]. > >> For more options, visit this group at > >> http://groups.google.com/group/algogeeks?hl=en. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. > > > > > > -- > Thanks & Regards, > Gaurav Gupta > > "Quality is never an accident. It is always result of intelligent effort" - > John Ruskin > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
