「String(API)」の版間の差分

提供: Eospedia
移動: 案内検索
(ファイルからの文字列出力)
(ファイルからの文字列出力)
行16: 行16:
  
 
=== ファイルからの文字列出力 ===
 
=== ファイルからの文字列出力 ===
fptInから読み出した文字列を出力します。<br>
+
fptInから読み出した文字列を出力します。(fptIn: stdinとすると標準入力、fptoutとすると標準出力となる)<br>
 
(mode&0x01: 0: 確認メッセージ有り, 1: 確認メッセージ無し): メッセージはfptOutに出力される。
 
(mode&0x01: 0: 確認メッセージ有り, 1: 確認メッセージ無し): メッセージはfptOutに出力される。
 
  extern String stringGetFromFile(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
 
  extern String stringGetFromFile(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);

2014年10月3日 (金) 07:03時点における版

General/Stringは文字列処理のためのAPI です。

定数

#define STRING_MAX_LENGTH (8192)
#define STRING_WORD_SEPARATOR  " ,\t" 
#define STRING_COMMENT_LINE_ID '#' 

構造体

typedef char*         String;
typedef unsigned long stringParaTypeInteger;
typedef float         stringParaTypeReal;

API

初期化

extern void stringInit(String s, char* message);

ファイルからの文字列出力

fptInから読み出した文字列を出力します。(fptIn: stdinとすると標準入力、fptoutとすると標準出力となる)
(mode&0x01: 0: 確認メッセージ有り, 1: 確認メッセージ無し): メッセージはfptOutに出力される。

extern String stringGetFromFile(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
extern char* __getStringData(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);

読み出した文字列からSTRING_WORD_SEPARATORを区切った1文字列を出力します。

extern String stringGetFromFileWithSkippingComment(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);

文字列抽出

文字列sからexceptionの各文字を区切り文字としたときにnth番目の文字列を出力します。

extern String stringGetNthWord(char* s, long nth, char* exception);

文字列sからexceptionの各文字を区切り文字としたときにnth番目の文字列を数値として出力します。

extern double stringGetNthRealData(char* s, long nth, char* exception);
extern long   stringGetNthIntegerData(char* s, long nth, char* exception);

文字列sについてinit文字目からend文字目までを出力します。

extern String stringGetWordFromField(char* s, long init, long end);

文字列sについてinit文字目からend文字目までを数値として出力します。

extern double stringGetRealDataFromField(char* s, long init, long end);
extern long   stringGetIntegerDataFromField(char* s, long init, long end);

文字列s1とs2についてn文字目またはs1の文字数まで比較して、同じ場合は1を、それ以外で0を返します。

extern long stringIsSame(String s1, String s2, long n);

文字列sの文字数を出力します。

extern long stringLength(String s);

文字列コピー

文字列srcをdstへn文字分コピーします。(戻り値: コピーした文字数)

extern long stringCopy(String dst, String src, long n);

メモリを確保して、文字列srcを出力します。

extern String stringDuplicate(String src);