I am grateful to people who help. I am grateful to cwr, lemnisca, TactX and pianorain. As I said "Whatever floats your boat" is not helpful. And since then all you've done is mix very little...
Type: Posts; User: the pooper
I am grateful to people who help. I am grateful to cwr, lemnisca, TactX and pianorain. As I said "Whatever floats your boat" is not helpful. And since then all you've done is mix very little...
It's a good idea, and I had also thought it might work, but when I tried it each run of the program would still end up mallocing the same block of memory. And so the pointer it returns and,...
Sorry, but you made it sound like you did not get that impression. Your attempt to clarify the article, however useful it may be to others, was posted as a reply to _me_. This made it sound like you...
No, I'm not worried about cryptographic strength randomness. But there may be two or more instances of this program running at any given moment and I don't want such instances to produce identical...
Yes, such a case *is* undesirable, which is why I stated I don't like their srand suggestion.
Hence the question mark in my post. I'm not saying "use the pid", I'm saying "can I use the pid?". Is...
I still don't much like their srand suggestion. Can I get the process ID? I personally would include that in the seed.
Ok, it appears their final recommended solution is effectively the same as what I had come up with, so that's good.
I see. I made the mistake of assuming that a byte is always 8 bits.
Since calling srand in one library will affect the result of rand in all other libraries is it considered good practice to leave that responsibility to the main program? They would have a better idea...
I'm not arguing that this is true, but I'm curious if this causes problems. Aren't there systems that natively use 2 bytes for a character? If so wouldn't this cause problems when mallocing...
I was making a distinction between the two types, which is pretty much the opposite of believing them to be the same. That quotes does not apply at all to what I said.
So ultimately you cannot...
Nothing in that article contradicts what I said, nor is any part of my post specific to Win32 (barring the results of the example I ran on my personal computer). The terms 32-bit and 64-bit reflect...
Why a long? Seems to me just a regular unsigned int is the correct data size, since 32-bit computers have 2^32 addressable memory locations and 64-bit computers have 2^64 addressable memory...
Perfect, thanks. If anyone's interested this was for creating a behind-the-scenes method of solving memory leak issues. Dangling pointers are handled as well. Below is an example of a fictional...
Is it possible to define one or more functions to execute just before a program terminates?
C89 (Technically only a draft, but identical to the final release as far as I know. If anyone knows where C89 is freely available, spread the word.)
and C99 (This one's the real thing.)
I can't provide a practical example either. But the point is that it is allowed to happen. Programming would be so much easier if we allowed ourselves to ignore errors that were uncommon. But robust...
But the standard says that argv[0] will be a pointer to a string only if argc is greater than 0. So if argc is 0 then argv[0] would be NULL, and the other requirements that are dependant on argc...
Unless I'm mistaken, you're also reading your value into unallocated memory, unless this isn't your actual code. You've declared x[0] to be a pointer to a struct, but the actual struct for x to point...
I hope everybody here realizes that there is a formula for calculating Fibonacci numbers.
(pow(1 + sqrt(5), n) - pow(1 - sqrt(5), n)) / (sqrt(5) * pow(2, n))This means that fib(10) can be calculated...
I think I will provide these additional checks through assertions. That way they can still be disabled in the final program.I remember now where I got the style of _FOO_H_. I was looking at the...
Is there a general style then for pre-processed constants in library code?The responsibility for this I decided to leave to the user. If they push some fixed number of items then they should know...
I've learned a lot thanks to people on this board. Below is an implementation of an array stack that I wrote and rewrote as I learned new or better concepts. I hope people will take a moment to...
Also, chris1985, I've found that with optimizations small functions such as this are usually inlined in the final program anyway.
If you're using gcc then the -S switch should output assembly...
Thanks anonytmouse. You've been a big help.