 
                            ...
| Code Block | ||
|---|---|---|
| 
 | ||
| 
void remove_spaces(char const *str, size_t slen) {
   char *p = (char *)str;
   size_t i;
   for (i = 0; i < slen && str[i]; i++) {
      if (str[i] != ' ') *p++ = str[i];
   }
   *p = '\0';
}
 | 
Compliant Solution
...
| Code Block | ||
|---|---|---|
| 
 | ||
| 
void remove_spaces(char *str, size_t slen) {
   char *p = str;
   size_t i;
   for (i = 0; i < slen && str[i]; i++) {
      if (str[i] != ' ') *p++ = str[i];
   }
   *p = '\0';
}
 | 
Non-Compliant Code Example
...
| Code Block | 
|---|
| 
/* Legacy function defined elsewhere - cannot be modified */
void audit_log(char *errstr) {  
  fprintf(stderr, "Error: %s.\n", errstr);
}
/* ... */
char const INVFNAME[]  = "Invalid file name.";
audit_log((char *)INVFNAME); /* EXP05-EX1 */
/* ... */
 | 
...