4 ms·
A character array seems like a natural way to me to represent a string of characters. But Unicode though...
by kizer 8y ago
A character array seems like a natural way to me to represent a string of characters. But Unicode though...
- deleted 8y ago[deleted]
- fulafel 8y agoAs C functions can't take arrays as arguments, you don't get very far this way.
- kizer 8y ago...you pass in a pointer to the first character. Arrays in C are simply contiguous spans of memory.
- fulafel 8y agoThid then has the problem that thr length is unknown, leading to well known problems.
- petee 8y agoWell if you wrote the array, or your program did, then you do know the length. Not a problem. Would it be nice if an array internally stored that? Sure. Does it? No. Is that a real problem? No, not really - its been solved and worked around for decades
- petee 8y agoThis is incorrect; a quick search with your first sentence will answer that
- fulafel 8y agoI found the opposite, and a quote from the standard: " A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation."
- petee 8y agoYou pass by reference, not by copy. It is still passing an array to a function though