초보자를 위한 C언어 프로그램 스타일 가이드 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

TECHNICAL FEATURE

Beginner Corner

112
Embedded World 113
TECHNICAL FEATURE

/*

* Copyright (C) 1989, 1990, Dabinch Enterprises. All

right reserved.

* Distributed by Free Software Foundation. Inc

* Usage:

* ansi2krn input_file output_file

* If no output_file is supplied, output goes to stout.

* there are no error message.

* ansi2krn recognizes functions by seeing a non-

keyword identifier

* at the left margin, followed by a left parenthesis

with a right

* parenthesis as the last character on the line.


/*
*/
* Here is a block Comment( * )
#include <stdio.h> /* system header file */ * The commnet text should be tabbed or spaced voer uniformly
#include <ctype.h> * The opening slash-star and closing star-slash are alone on
#include string_h.h /* user header file */ a line.

#include malloc_h.h */

/*
#define X_DPI 300 /* constant define */
** Alternate format( )
#define Y_DPI 300 ,
** *
/* constant function macro */ ** Here is a block Comment
#define isidchar(ch) (isalnum(ch) || (ch) == _ ) */
#define isidfirstchar(ch) (isalpha(ch) || (ch) == _ )

typedef int *(*PFT)(); /* type define */

extern int value[]; /* extern */

char char buffer; /* non-static */

static int tmp ; /* static */

114
if(argc > 1) {
/* Get input file from command line */
if(freopen(argv[1], r ,stdin) == NULL) {
perror(argv[1]);
}
}

struct boat {
int wllength; /* water line length in meters */
int type; /* see below */
long sailarea; /* sail area in square mm */

if(a == EXECPTION ) { };

b = TRUE; /* special case */


} else { /* define for boat.type */
b = isprime(a); /* works only for odd a */ #define KETCH (1)
} #define YAWL (2)
#define SLOOP (3)
#define SQRIG (4)
#define MOTOR (5)

enum bt {KETCH = 1, YAWL, SLOOP, SQRIG, MOTOR};

struct boat {

int wllength; /* water line length in meters */

enum bt type; /* what kind of boat */

long sailarea /* sail area in square mm */

};

char *s, *t, *u; /* case 1 */


char *s, t, u; /* case 2 */

Embedded World 115


TECHNICAL FEATURE

int x = 1;
char *msg = message ;
struct boat winner[] = {
{40, YAWL, 6000000L},
{28, MOTOR, 0L},
{0},
};

typedef struct splodge_t {

int sp_count;

char *sp_name, *sp_alias;

} splodge_t;

116

You might also like