...
Adding in the const keyword will generate a compiler warning, as the assignment of CMUfullname to school discards the const qualifier. Any modifications to the contents of scholl school after this assignment will lead to errors.
...
| Code Block | ||
|---|---|---|
| ||
char* const CMUfullname = "Carnegie Mellon";
/* get school from user input and validate */
if (strcmp(school,"CMU")) {
//assuming school is properly allocated above
strcpy(school, CMUfullname);
}
|
...
| Wiki Markup |
|---|
[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1993/N0389.asc] \[[ISO/IEC 9899-1999:TC2|AA. C References#ISO/IEC 9899-1999TC2]\] Section 6.7.8, "Initialization" \[Lockheed Martin 2005\] Lockheed Martin. Joint Strike Fighter Air Vehicle C+\+ Coding Standards for the System Development and Demonstration Program. Document Number 2RDU00001, Rev C. December 2005. AV Rule 151.1 |