tstring.h

来自「Software Development in C: A Practical A」· C头文件 代码 · 共 90 行

H
90
字号
//---------------------------------------------------------
/*
File name:	Tstring.h
Comments:	This file contains the definitions needed to 
			use the text_string type.
*/

#ifndef TSTRING_H
#define TSTRING_H


//---------------------------------------------------------
// Constants

#define TEXT_STRING_MAX_LENGTH 60

// End constants
//---------------------------------------------------------



//---------------------------------------------------------
// Enumerated types

typedef enum 
{
	TSE_NO_ERROR = 0,

	TSE_FIRST_WARNING = 100,
	TSE_EMPTY_SOURCE_CHAR_ARRAY,

	TSE_FIRST_ERROR = 1000,
	TSE_SOURCE_CHAR_ARRAY_TOO_LONG,
	TSE_INVALID_CHARACTER,
	TSE_INDEX_OUT_OF_RANGE,
	TSE_INDEX_AFTER_END_OF_STRING,
	TSE_EMPTY_TEXT_STRING,
	TSE_STRING_IS_FULL
} text_string_error;

// End enumerated types
//---------------------------------------------------------



//---------------------------------------------------------
// Type definitions

/* This defines the text_string type as an array of 
TEXT_STRING_MAX_LENGTH characters. */
typedef char text_string[TEXT_STRING_MAX_LENGTH];

// End type definitions
//---------------------------------------------------------



//---------------------------------------------------------
// Prototypes

/* The TextStringInitString function must be called on a 
text_string variable before it is used.*/
void TextStringInitString(text_string theString);

text_string_error TextStringSetString(
						text_string theString,
					    char charArray[]);

text_string_error TextStringSetCharacter(
						text_string theString,
						char theCharacter,
						int characterIndex);

int TextStringGetCharacter(text_string theString,
 						   int characterIndex);

text_string_error TextStringAppendCharacter(
						text_string theString,
						char theCharacter);

int TextStringPrintString(text_string theString);

// End prototypes
//---------------------------------------------------------


#endif

// End Tstring.h
//---------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?