Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CSSE2310/CSSE7231
C Programming Style Guide
Version 2.0.4
Programs written for CSSE2310/7231 assignments must follow the style guidelines outlined in this document.
Where the style guide is open to interpretation, the choices you make regarding your personal style must be
consistent throughout your project.
1 Naming Conventions
1.1 Variable and File names
Variable names and file names will begin with a lowercase letter and names with multiple words will use initial
capitals for subsequent words. Names that are chosen should be meaningful and Hungarian notation is NOT to be
used. Source files must be named with the suffix .c or .h (lower case).
Example variable names: book, newCount, setWordLength
Example filenames: hello.c, stringRoutines.c, shared.h
Unacceptable variable names: FILE *fp; char *aPtr; char *thingStr;
1.2 Defined constants and macros
Preprocessor constants and macros, ie. those defined using #define, must be named using all uppercase letters,
with underscores ( ) used to seperate multiple words.
NOTE: Variables declared with the const keyword are to use variable naming, as per 1.1.
Examples: MAX BIT, DEFAULT SPEED
1.3 Function names
Function names should all be lowercase and use underscores to separate multiple words.
Example function names: main(), reset secret string()
1.4 Type names
Type names (i.e. from typedefs), structure and union names should begin with capital letters and use initial capitals
for subsequent words.
Example typedef/structure/union names: Contact, FileData, struct Node
/∗ A player with in the game ∗/
s t r u c t Player {
char ∗name ;
i n t s co r e ;
s t r u c t Player ∗next ;
} ;
Example 1: Struct naming and declaration
/∗ Point ( coo rd inate ) ∗/
typede f s t r u c t {
i n t x ;
i n t y ;
} Point ;
Example 2: Typedef struct naming and declaration
1
1.5 Enumerated Types
Enumerated types must be named in the same way as any other type (see 1.4). Members of an enumerated type
must follow the same naming as constants (see 1.2).
/∗ Card s u i t s ∗/
enum CardSuits {
CLUBS, DIAMONDS, HEARTS, SPADES
} ;
Example 3: Enumerated type naming and horizontal
layout
/∗ Program ex i t codes ∗/
enum ExitCodes {
EXIT SUCCESS = 0 ,
EXIT ARGS = 1 ,
EXIT FAILURE = 2
} ;