char型の文字列p[100],q[100]に対してp++としてからq[0]=p[0]とすればp++とする前のp[1]がq[0]に代入されると思っていたのですが違うのでしょうか?
また、下記の記述はFileRead_gets関数で1行目を読み込んだ後に再びFileRead_gets関数を使用することで2行目を読み込めると仮定して書いているのですが、この方法で改行を行うことは出来るのでしょうか?
以上の2点をどなたかよろしくお願いします。
#include "DxLib.h"
#include <math.h>
struct Data{
char name[32];
};
struct Data readstr[4];
void hoge(){
int file,i;
int cut=0,m=0,ed=0,j=0;
int text[32];
char textc[32];
char line[999];
file=FileRead_open( "TestData.txt" ) ;
if(file==NULL){printfDx("read error\n");return;}
FileRead_gets(line,999,file);
while(1){
cut==0;
for(i=0;i<31;i++){
switch(_mbclen((BYTE*)line)){
case 1:
if(line[0]==','){cut=1;}
else if(line[0]=='\0'){cut=2;i--;}
else if(line[0]==EOF){ed=1;}
else{textc[i]=line[0];}
break;
case 2:
textc[i]=line[0];
textc[i+1]=line[1];
line++;
i++;
break;
}
if(cut==1){break;}
else if(cut==2){
FileRead_gets(line,999,file);
if(line[0]==EOF){ed=1;}
else{continue;}
}
line++;
}
strcpy(readstr[m].name,textc);
m++;
}
FileRead_close(file) ;
DrawFormatString( 0, 0, GetColor(255,255,255), "%s,%s,%s,%s",readstr[0].name,readstr[1].name,readstr[2].name,readstr[3].name);
WaitKey();
}
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); //ウィンドウモード変更と初期化と裏画面設定
hoge();
DxLib_End(); // DXライブラリ終了処理
return 0;
}