开发者

Issue with string length 76

I am at a loss here. Will post my code in a short while...just that its too long to extract portions of the "tro开发者_StackOverflowubling" giving code. Will expalin my issue here: I store a string(path to a file or directory) in an array of structure { char *path; size_t path_len} where path is the string and path_en its length. On inserting the path_len is 76. On extracting from the array with strncpy the string length becomes 78 or even a simple strlen of the string within the array says 77.

All other cases with original string length lesser then 77 works just fine.

I am baffled.


With strncpy -- do you remember to null terminate the resulting copied string?

Strncpy does not null terminate strings if they are longer than N (N being the 3rd argument you pass to strncpy)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜