Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to write a program in C that does nothing - not even taking up memory?

Tags:

c

This is a tricky C question asked in interview: Write a program that does nothing, not even taking up memory.

Is it possible to do so?

like image 714
Vishwanath Dalvi Avatar asked Jan 06 '11 08:01

Vishwanath Dalvi


1 Answers

All programs use memory. When you run the program, the OS will set up an address space for the program, copy its arguments into its process space, give it a process ID and a thread, give it some file descriptors for I/O, etc. Even if your program immediately terminates you still use up this memory and CPU time.

like image 107
templatetypedef Avatar answered Nov 15 '22 22:11

templatetypedef