| | |
why use of size 0 or 1 array in structure for URI'S etc
![]() |
•
•
Join Date: May 2008
Posts: 33
Reputation:
Solved Threads: 4
0
#12 Oct 14th, 2009
It's purely theoretical. You shouldn't have to compile it to see that it will crash.
The buffer will be filled with unknown data after the first two known values so the four bytes at BYTE *data will be some random value which surely will not be the desired pointer value.
The zero sized array version ->data member will always point to the next byte after the known values in the buffer.
The buffer will be filled with unknown data after the first two known values so the four bytes at BYTE *data will be some random value which surely will not be the desired pointer value.
The zero sized array version ->data member will always point to the next byte after the known values in the buffer.
0
#13 Oct 14th, 2009
•
•
•
•
You shouldn't have to compile it to see that it will crash.
-Tommy (For Great Justice!) Gunn
•
•
Join Date: May 2008
Posts: 33
Reputation:
Solved Threads: 4
0
#14 Oct 14th, 2009
•
•
•
•
All I see is undefined behavior from using a bogus pointer. I have debugged many cases where the same problem does not crash, so your theoretical result does not mean anything unless you can back it up with empirical data. The problem is that saying things like this will crash gives beginners a false sense of security that the program will fail spectacularly if they do something wrong. It is just as probable that the program will fail silently and continue running until the damage done is very costly.
I will try to avoid that in the future. I forget that what's 'obvious' to me is not to every one
![]() |
Similar Threads
- size of array (C++)
- How to create a byte array/structure (C++)
- Size of array passed as parameter. (C++)
- Max size of Array (C++)
- how to increase the size of an array? (C)
Other Threads in the C Forum
- Previous Thread: 2d-board algorithm: Total number of different moves to reach a location
- Next Thread: Adding 2 arrays together
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi





