Some compilers hack this behavior by treating strlen as internal command, and whenever possible, it's replaced by actual string length. Furthermore, strings don't know their length, thus a length retrieval operation is O(n) instead of O(1) as in Pascal. This is the biggest cause of memory leaks, buffer overruns, etc. must be managed bt the programmer, just like another pointers. Strings in C is still like how it was in 1971 when the language comes out: Programmer managed pointer to array of char ending with #0. If you declare an array of integer of size 10, followed by another integer, you can access the array at index 10 and it's not an error! Pascal has all of them
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |