This program runs perfectly on one machine ...
Submitted by: AdministratorThis program runs perfectly on one machine, but I get weird results on another. Stranger still, adding or removing a debugging printout changes the symptoms.
Lots of things could be going wrong; here are a few of the more common things to check:
* uninitialized local variables
integer overflow, especially on 16-bit machines, especially of an intermediate result when doing things like a * b / c
* undefined evaluation order
* omitted declaration of external functions, especially those which return something other than int, or have ``narrow'' or variable arguments
* dereferenced null pointers
* improper malloc/free use: assuming malloc'ed memory contains 0, assuming freed storage persists, freeing something twice, corrupting the malloc arena
* pointer problems in general
* mismatch between printf format and arguments, especially trying to print long ints using %d
* trying to allocate more memory than an unsigned int can count, especially on machines with limited memory
* array bounds problems, especially of small, temporary buffers, perhaps used for constructing strings with sprintf
* invalid assumptions about the mapping of typedefs, especially size_t
* floating point problems
* anything you thought was a clever exploitation of the way you believe code is generated for your specific system
Proper use of function prototypes can catch several of these problems; lint would catch several more.
Submitted by: Administrator
Lots of things could be going wrong; here are a few of the more common things to check:
* uninitialized local variables
integer overflow, especially on 16-bit machines, especially of an intermediate result when doing things like a * b / c
* undefined evaluation order
* omitted declaration of external functions, especially those which return something other than int, or have ``narrow'' or variable arguments
* dereferenced null pointers
* improper malloc/free use: assuming malloc'ed memory contains 0, assuming freed storage persists, freeing something twice, corrupting the malloc arena
* pointer problems in general
* mismatch between printf format and arguments, especially trying to print long ints using %d
* trying to allocate more memory than an unsigned int can count, especially on machines with limited memory
* array bounds problems, especially of small, temporary buffers, perhaps used for constructing strings with sprintf
* invalid assumptions about the mapping of typedefs, especially size_t
* floating point problems
* anything you thought was a clever exploitation of the way you believe code is generated for your specific system
Proper use of function prototypes can catch several of these problems; lint would catch several more.
Submitted by: Administrator
Read Online C Programming Job Interview Questions And Answers
Top C Programming Questions
☺ | Why does this code crash? |
☺ | What is wrong with this declaration? |
☺ | How can I read/write structures from/to data files? |
☺ | What does static variable mean in c? |
☺ | How can I increase the allowable number of simultaneously open files? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |