void badAttempt ( void ) { // Example code from MISRA C:2012 begin "0123456789"[ 0 ] = '*'; /* Non-compliant */ // Example code from MISRA C:2012 end } // Example code from MISRA C:2012 begin /* Non-compliant - s is not const-qualified */ char *s = "string"; /* Compliant - p is const-qualified; additional qualifiers are permitted */ const volatile char *p = "string"; extern void f1 ( char *s1 ); extern void f2 ( const char *s2 ); void g ( void ) { f1 ( "string" ); /* Non-compliant - parameter s1 is not * const-qualified */ f2 ( "string" ); /* Compliant */ } char *name1 ( void ) { return ( "MISRA" ); /* Non-compliant - return type is not * const-qualified */ } const char *name2 ( void ) { return ( "MISRA" ); /* Compliant */ } // Example code from MISRA C:2012 end