New answers tagged

0

The main problem with static is that it destroys reentrancy - it’s why you can’t "nest” calls to strtok. You only have a single instance of that object over the lifetime of the program. It is created and initialized once at program startup, and persists until program exit. It can be confusing to read code like void foo( void ) { static int x = 5; .....


0

Apparently, this question mixes up the problem of creating dynamically resizable arrays / vectors with the problem of how to store a graph. The first one can be solved the same way as dynamic vectors are implemented in other languages (for example, in C++): by implementing a vector as a data structure with a capacity apart from its size, and whenever the ...


3

There are many kinds of graphs, you're apparently thinking of simple directed graphs without edge weights. Different implementations may have different associated memory/performance costs depending for example on the edge density etc., and of course there's no such thing as "most efficient in terms of both computational power and memory consumption"...


3

The context of this paragraph is explaining storage duration, not the keyword static. The parenthetical statement in question is just referring to the fact that there are many things with static storage duration that don't use the keyword static. For example, any file scope variable has static storage duration, despite not being marked with the keyword ...


3

TL;DR: different level of abstractions. There is really no such thing as an object, there are just 1’s and 0’s and interpretations of them. The CPU doesn’t know about objects, so the same question would apply for it: how can you you have a compiler for a language with objects, when the CPU it targets doesn’t know about objects? And the answer is the same, ...


13

Higher level abstractions are routinely implemented with lower level building blocks. For example, C higher level language constructs are themselves implemented with lower level assembler instructions. And the same applies to object orientation, which is often implemented with non-object oriented techniques. Objects are made of data and behavior. C does not ...


Top 50 recent answers are included