MY mENU


Tuesday 26 June 2012

What are the different storage classes in C?


C has three types of storage: automatic, static and allocated. Variable having block scope and without static specifier have automatic storage duration.
Variables with block scope, and with static specifier have static scope. Global variables (i.e, file scope) with or without the static specifier also have static scope.
Memory obtained from calls to malloc(), alloc() or realloc() belongs to allocated storage class.

Monday 25 June 2012

What are the differences between malloc() and calloc()?


There are 2 differences.
First, is in the number of arguments. malloc() takes a single argument(memory required in bytes), while calloc() needs 2 arguments(number of variables to allocate memory, size in bytes of a single variable).


Secondly, malloc() does not initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.

Saturday 23 June 2012

Advantages of a macro over a function?


Macro gets to see the Compilation environment, so it can expand ___TIME__ __FILE__ #defines. 
It is expanded by the preprocessor. For example, you can’t do this without macros


#define PRINT(EXPR) printf( #EXPR “=%d\n”, EXPR) 


PRINT( 5+6*7 ) // expands into printf(”5+6*7=%d”, 5+6*7 );


You can define your mini language with macros:


#define strequal(A,B) (!strcmp(A,B))


Macros are a necessary evils of life. The purists don’t like them, butwithout it no real work gets done.

Friday 22 June 2012

What does static variable mean?


there are 3 main uses for the static.
1. If you declare within a function: It retains the value between function calls
2.If it is declared for a function name: By default function is extern..so it will be visible from other files if the function declaration is as static..it is invisible for the outer files
3. Static for global variables: By default we can use the global variables from outside files If it is
static global..that variable is limited to with in the file

Thursday 21 June 2012

"union" Data Type What is the output of the following program? Why?


#include
main() {
typedef union {
int a;
char b[10];
float c;
}
Union;
Union x,y = {100};
x.a = 50;
strcpy(x.b,"hello");
x.c = 21.50;
printf("Union x : %d %s %f n",x.a,x.b,x.c);
printf("Union y : %d %s %f n",y.a,y.b,y.c);
}

Wednesday 20 June 2012

Linked Lists -- Can you tell me how to check whether a linked list is circular?


Create two pointers, and set both to the start of the list. Update each as follows:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next;
if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2) {
print ("circular");
}}


If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item before that. Either way, its either 1 or 2 jumps until they meet.

Tuesday 19 June 2012

printf() Function- What is the difference between "printf(...)" and "sprintf(...)"?


sprintf(...) writes data to the character array whereas printf(...) writes data to the standard output device.

Compilation How to reduce a final size of executable?
Size of the final executable can be reduced using dynamic linking for libraries.

Monday 18 June 2012

malloc() Function- What is the difference between "calloc(...)" and "malloc(...)"?


1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * size). malloc(...) takes in only a single argument which is the memory required in bytes. malloc(...) allocated bytes of memory and not blocks of memory like calloc(...).
2. malloc(...) allocates memory blocks and returns a void pointer to the allocated space, or NULL if there is insufficient memory available.
calloc(...) allocates an array in memory with elements initialized to 0 and returns a pointer to the allocated space. calloc(...) calls malloc(...) in order to use the C++ _set_new_mode function to set the new handler mode.

Sunday 17 June 2012

printf() Function in C Language


What is the output of printf("%d")?
1. When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothing after %d so compiler will show in output window garbage value.
2. When we use %d the compiler internally uses it to access the argument in the stack (argument stack). Ideally compiler determines the offset of the data variable depending on the format specification string. Now when we write printf("%d",a) then compiler first accesses
the top most element in the argument stack of the printf which is %d and depending on the format string it calculated to offset to the actual data variable in the memory which is to be printed. Now when only %d will be present in the printf then compiler will calculate the correct
offset (which will be the offset to access the integer variable) but as the actual data object is to be printed is not present at that memory location so it will print what ever will be the contents of that memory location.
3. Some compilers check the format string and will generate an error without the proper number and type of arguments for things like printf(...) and scanf(...).

Friday 8 June 2012

Improved Use of System cache


Open registry by going to START-RUN and entering regedit. Navigate to the registry key
that is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager
\MemoryManagement . Look for value of "LargeSystemCache". If available, do one of the
following: If the computer is a workstation, set its value to 0. If it is a server set a value of 1.

Thursday 7 June 2012

Display Your Own Error Messages


When you try to delete Microsoft Outlook from the desktop, you get the warning message "The Outlook Desktop icon provides special functionality and we recommend that you do not remove it." If you like, you can edit that message to display whatever you want. In the CLSID's subkeyfor example, {00020D75-0000-0000-C000-000000000046} for Microsoft Outlook you'll find the value Removal Message. Edit this value to whatever text you want, and your warning message will appear whenever someone tries to delete the icon. This is just an example. Follow the suit for customizing the error messages for other icons too!

Wednesday 6 June 2012

All About Your Recycle Bin


Add rename to the menu:


HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder
"Attributes"=hex:50,01,00,20


Add delete to the menu:


HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder
"Attributes"=hex:60,01,00,20


Add rename and delete to the menu:


HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder
"Attributes"=hex:70,01,00,20


Restore the recycle bin to Windows defaults including un-deleting the icon after deletion:
Restore the icon.


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer
\Desktop\NameSpace\{645FF040-5081-101B-9F08-00AA002F954E}
@="Recycle Bin"


Reset Windows defaults.


HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder
"Attributes"=hex:40,01,00,20


Other edits to the recycle bin icon:


HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder
"Attributes"=hex:40,01,01,20 ... standard shortcut arrow
"Attributes"=hex:40,01,02,20 ... a different shortcut arrow
"Attributes"=hex:40,01,04,20 ... and still another shortcut arrow
"Attributes"=hex:40,01,08,20 ... make it look disabled (like it's been cut)


For Windows XP and 2000 you have to also edit the following key:


HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645F
F040-5081-101B-9F08-00AA002F954E}




Tuesday 5 June 2012

Switch to Windows' basic search tool


Open the Registry Editor. Now Navigate to HKEY_CURRENT_USER\Software \Microsoft\Windows\CurrentVersion\Explorer \ Cabinet State. Go to Edit New String Value. Name the new value. Double-click the new value, type no in the Value Data text box, and click OK. Close the Registry Editor, and restart the system. To switch back to the Search Companion, just go back to the Registry Editor, and change the Value Data to yes.

Monday 4 June 2012

Faster Network Access


When you use My Network Places to browse for other machines on your network, Windows XP first checks for the scheduled tasks on the target machine before listing the shared resources present on the computer. We can do a registry hack to avoid this delay. Invoke the Registry Editor by typing regedit at the command line. Open the following Registrykey:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace. Delete the following key {D6277990-4C6A-11CF- 8D87-00AA0060F5BF}. Now close the Registry and reboot.

Sunday 3 June 2012

Customize the “Send To” Option


Adding new locations and programs and taking away existing ones that you never use from this menu is very simple. It's easy to hack. Go to C:\Documents and Settings\\SendTo, where is your username with which you login to your system. The older will be filled with shortcuts to all the locations you find on your “Send To” context menu. To remove an item from the Send To menu, delete the shortcut from the folder. To add an item to the menu, add a shortcut to the folder by highlighting the folder, choosing File  New Shortcut, and follow the instructions for creating a shortcut. The new setting will take effect immediately.

Saturday 2 June 2012

Add “Copy To Folder” and “Move To Folder” in a Right-Click Menu


Go to HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers. Shellex. It tells you it's a shell extension key that lets you customize the user shell or the interface. Create a new key called Copy To. Set the value to {C2FBB630-2971-11d1- A18C-00C04FD75D13}. Create another new key called Move To. Set the value to {C2FBB631-2971-11d1-A18C-00C04FD75D13}. Exit the Registry. The changes should take effect immediately. The Copy To Folder and Move To Folder options will appear. When you right-click a file and choose one of the options, you'll be able to move or copy the file using a dialog box.

JavaScript Interview Question part-2


1. Choose the client-side JavaScript object?
A.  Database
B.   Cursor
C.  Client
D.  FileUpLoad

2.  Which of the following is not considered a JavaScript operator?
A.  new
B.  this
C.  delete
D.  typeof

3.  ______method evaluates a string of JavaScript code in the context of the specified object.
A.  Eval
B.   ParseInt
C.  ParseFloat
D.  Efloat


Friday 1 June 2012

Un-install Wordpad, Automatic Update, Messenger, Pinball etc


Use Notepad or another text editor to open the Setup Information file, sysoc.inf, which is generally found in the C:\WINDOWS\INF folder. For this folder to be visible, you will have to enable hidden folders by going into Windows Explorer and choosing Tools Folder Options View Show Hidden Files and Folders. The lines in the file follow the format: 


program=program.dll,OcEntry,program.inf,,numeral


The Pinball game entry, as an example, looks like this:
Pinball=ocgen.dll,OcEntry,pinball.inf,HIDE,7.


Remove the word HIDE from the entry that refers to the component you want to remove. Save the sysoc.inf file, and run the Windows Components Wizard under Add/Remove programs. The component will now show up in the wizard. Remove it as you would any other component.

JavaScript interview Questions part-1


1.  Why so JavaScript and Java have similar name?
A.  JavaScript is a stripped-down version of Java
B.  JavaScript’s syntax is loosely based on Java’s
C.  They both originated on the island of Java
D.  None of the above

2.  When a user views a page containing a JavaScript program, which machine actually executes the script? A.  The User’s machine running a Web browser
B.   The Web server
C.  A central machine deep within Netscape’s corporate offices
D.  None of the above


3.  ______ JavaScript is also called client-side JavaScript.
A.  Microsoft
B.  Navigator
C.  LiveWire
D.  Native
4.  __________ JavaScript is also called server-side JavaScript.
A.  Microsoft
B.   Navigator
C.  LiveWire
D.  Native
5.  What are variables used for in JavaScript Programs?
A.  Storing numbers, dates, or other values
B.   Varying randomly
C.  Causing high-school algebra flashbacks
D.  None of the above
6.  _____ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation. A.  Client-side
B.   Server-side
C.  Local
D.  Native

7.  What should appear at the very end of your JavaScript?
The
B.    The
D. 

16.  Inside which HTML element do we put the JavaScript?
A. 
B.  
C.