...
The following noncompliant code example simply shows the standard string handling function strlen()
being called with a plain character string, a signed character string, and an unsigned character string. The strlen()
functions takes a single argument of type const char
*.
Code Block | ||||
---|---|---|---|---|
| ||||
size_t len; char cstr[] = "char string"; signed char scstr[] = "signed char string"; unsigned char ucstr[] = "unsigned char string"; len = strlen(cstr); len = strlen(scstr); /* warns when char is unsigned */ len = strlen(ucstr); /* warns when char is signed */ |
...
The compliant solution uses plain char
for character data.
Code Block | ||||
---|---|---|---|---|
| ||||
size_t len; char cstr[] = "char string"; len = strlen(cstr); |
...