...
Non-Compliant Coding Example
Code Block | ||
---|---|---|
| ||
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char *char *pwd; char *home; pwd = getenv("PWD"); if printf("!pwd) = %s.\n", pwd); char *return -1; home = getenv("HOME"); if printf("pwd = %s.\n", pwd); printf("home = %s.\n", home); // see if home is the same as pwd if (!home) return -1; if (strcmp(pwd, home) == 0) { puts("pwd and home are the same.\n"); } else { puts("pwd and home are NOT the same.\n"); } return 0; } |
Compliant Solution
Code Block | ||
---|---|---|
| ||
...