Last active
December 10, 2015 02:58
-
-
Save alphaKAI/4371611 to your computer and use it in GitHub Desktop.
てふてふの文章生成の処理 自分用ライブラリhttps://github.com/alphaKAI/alpha_kai_NET_my_lib の一部なので単体で動作しません
自分用ライブラリのcheck関数 ReturnString関数 how_line関数 GetRandom関数を使ってるのでそっちをみないとわかんない感じです
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* make_string関数 */ | |
int make_string(const char *filename, char *buf, const int size){ | |
int i; | |
int sum; | |
int dum; | |
int ck; | |
char str[1000]; | |
int get_line; | |
int return_sum; | |
int count; | |
count=1; | |
i=0; | |
/* ファイルチェック */ | |
ck=check(filename); | |
if(ck==0){ | |
printf("ERROR:\n"); | |
printf("読み込み対象のファイルが存在しません\n"); | |
return 1; | |
} | |
else if(ck==1){ | |
/* 引数のファイル名の行数取得 */ | |
sum = how_line(filename); | |
/* 文字列のメモリサイズの上限(?) */ | |
dum=GetRandom(size); | |
while(i!=1){ | |
printf("%d==============\n", count); | |
get_line=GetRandom(sum); | |
return_sum = ReturnStrings(filename, get_line, str, 1000); | |
if(return_sum==-1){ | |
printf("ERROR:\n"); | |
printf("ReturnStrings関数でファイルオープンに失敗しました\n"); | |
return -1; | |
} | |
else if(return_sum==-2){ | |
printf("ERROR:\n"); | |
printf("ReturnStrings関数でデータ取得に失敗しました\n"); | |
return -2; | |
} | |
/* 文字列連結 */ | |
strcat(buf,str); | |
/* 最大上限より大きいのでi=1で終了 */ | |
if(sizeof(buf)>=dum){ | |
break; | |
} | |
SLEEP3; | |
count++; | |
/* 改行削除 */ | |
strtok(buf,"\n\0"); | |
} | |
} | |
else{ | |
printf("ERROR:\n"); | |
printf("check関数からの返り値が異状です\n"); | |
return 2; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment