Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Please help optimize (and standarize) this code...
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Michael Mair, post: 2408028"] size_t is the type of the result of the sizeof operator and the type of argument taken by the dynamic memory allocation routines malloc/calloc/realloc -- so, basically, every object you work with has a size in bytes which can be expressed in size_t. The same guarantee does not hold for short, int, long of either signed or unsigned variety. So, using size_t for your index variables, you can _never_ (*) go wrong. The downside is that you have to be more careful with your loop tests as unsigned integer types never can provide values <0. (*) never: There are no absolutes. Using automatic or static or dynamically allocated storage, within standard C you will be on the safe side. Note that size_t has not to be large enough to count, for example, the number of bytes in a file. [snip: solved problem] Cheers Michael [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Please help optimize (and standarize) this code...
Top