tweaks in C

What does following code mean ?

scanf(“%[^a]“,dummy);

It means that continue accepting a string before you encounter the character ‘a’. This can be used to input a string containing white space characters by putting ‘\n’ as the character where to stop.

atomicity and alignment of data in memory

A data item is aligned in memory when its address is a multiple of its size in bytes. For instance, the address of an aligned short integer must be a multiple of two while the address of an aligned integer must be a multiple of four.
Why is it important to know about alignment ?
Assembly language [...]

return and exit from main: difference

What is the difference between returning from main with some exit code and calling exit giving the exit code as parameter ?
Basically the difference between following programs !
//ret.c
int main()
{
return 43;
}
//exit.c
int main()
{
exit(43);
}
well, there are three ways for the processes to exit: -
1. Voluntary exit (implicit)
2. Voluntary exit (explicit)
3. Involunatary exit
Voluntary exit can be implicit [...]

how to enforce the instantiation of objects on heap ?

A nice question, I came through while being in an interview. Well, so how do you make sure that the object can be instantiated only on heap and not on stack ? so, if you are of the kind who don’t think without being given the use and purpose .. well the purpose is that [...]

fork and vfork

quick question: what’s the difference between fork() and vfork() system calls ?
quick answer: vfork() system call creates a process that shares the memory address space of its parent.
details:
fork() is implemented by linux as a clone() system call whose flags parameter specifies both a SIGCHLD signal and all the clone flags cleared and whose child_stack parameter [...]

difference between jmp and far jmp

a quick question in interviews: what is the difference between jmp and far jmp ?
a quick answer: far jmp modified both CS and EIP while jmp modifies only EIP.