fwrintfでテキストファイルに表示するには
Posted: 2010年3月17日(水) 23:06
fwprintfでテキストファイルに表示されないのですが。
void inEditString(TCHAR listboxstr[256][256])
{
int strcount=0,count2=0,count3=0,flag=0;
TCHAR editstr[MAX_ST[/url];
TCHAR listboxstrbuffer[256][256];
GetWindowText(editbox2,editstr,256);
fp=_wfopen(_T("Listbox2.txt"),_T("r+"));
if(fp==NULL)
{
MessageBox(hWnd,_T("ファイルが開きません。"),_T("エラー"),MB_OK);
}
while(fwscanf(fp,_T("%s"),listboxstr[strcount])!=EOF)
{
strcount++;
}
while(count2<(strcount+1))
{
if(flag==0)
{
if(wcscmp(editstr,listboxstr[count3])>=NULL)
wcscpy(listboxstrbuffer[count2],editstr);
count2++;
flag=1;
}
wcscpy(listboxstrbuffer[count2],listboxstr[count3]);
count2++;
count3++;
}
fclose(fp);
fp=_wfopen(_T("Listbox2.txt"),_T("w"));
if(fp==NULL)
{
MessageBox(hWnd,_T("ファイルが開きません。"),_T("エラー"),MB_OK);
}
strcount=0;
while(strcount<count2)
{
fwprintf(fp,_T("%s"),listboxstrbuffer[strcount]);
strcount++;
}
}
なのですが、変な変数名がありますが気にしないでください、
ブレイクポイントをfwprintf(fp,_T("%s"),listboxstrbuffer[strcount]);
の所にやったのですが、listboxstrbuffer[strcount]の所を表示させたのですが、
文字列は入っているのにそして再実行するとテキストファイルに表示されません。
なぜでしょうか?
void inEditString(TCHAR listboxstr[256][256])
{
int strcount=0,count2=0,count3=0,flag=0;
TCHAR editstr[MAX_ST[/url];
TCHAR listboxstrbuffer[256][256];
GetWindowText(editbox2,editstr,256);
fp=_wfopen(_T("Listbox2.txt"),_T("r+"));
if(fp==NULL)
{
MessageBox(hWnd,_T("ファイルが開きません。"),_T("エラー"),MB_OK);
}
while(fwscanf(fp,_T("%s"),listboxstr[strcount])!=EOF)
{
strcount++;
}
while(count2<(strcount+1))
{
if(flag==0)
{
if(wcscmp(editstr,listboxstr[count3])>=NULL)
wcscpy(listboxstrbuffer[count2],editstr);
count2++;
flag=1;
}
wcscpy(listboxstrbuffer[count2],listboxstr[count3]);
count2++;
count3++;
}
fclose(fp);
fp=_wfopen(_T("Listbox2.txt"),_T("w"));
if(fp==NULL)
{
MessageBox(hWnd,_T("ファイルが開きません。"),_T("エラー"),MB_OK);
}
strcount=0;
while(strcount<count2)
{
fwprintf(fp,_T("%s"),listboxstrbuffer[strcount]);
strcount++;
}
}
なのですが、変な変数名がありますが気にしないでください、
ブレイクポイントをfwprintf(fp,_T("%s"),listboxstrbuffer[strcount]);
の所にやったのですが、listboxstrbuffer[strcount]の所を表示させたのですが、
文字列は入っているのにそして再実行するとテキストファイルに表示されません。
なぜでしょうか?