Reputation: 36414
suppose there is a string of characters in an array of d[20] . How to convert to a string d so that i can use it in string functions like strcmp..
Upvotes: 1
Views: 204
Reputation: 133669
it's already something on which you can operate with standard string functions, assuming that it ends with '\0'
since it's a requirement: it needs to know when the string ends.
You can prepare the space of char[]
by memsetting it with memset(string, 0, length)
.
Upvotes: 1
Reputation: 37702
Null terminate the string. That is, set the character after the last character in your string to zero.
Upvotes: 2
Reputation: 18456
It must be null-terminated. That's the only requirement. I presume you know how to do that.
Upvotes: 3