|
조진수 님이 쓰신 글 :
: 소스는 아래와 같이 했구여.... jinso0.txt에 시리얼 데이타를 쓸려고 하는데.... 안돼네여... 답변좀
:
: 부탁드립니다.
:
:
: void __fastcall TForm1::ComPortRxChar(TObject *Sender, int Count)
: {
: char *Str = "";
: FILE *fdata;
: char *sHex;
: char temp;
: Byte szHex[64];
: String str1,str2[14];;
: int i;
:
: fdata = fopen("c:\\jinso0.txt","wt");
:
: ComPort->ReadStr(str1,Count);
:
: sHex=str1.c_str();
: for (int i=0; i< str1.Length(); i++)
: {
: szHex[i]=sHex[i];
: }
: for (int i=0; i< str1.Length(); i++)
: {
: str2[i].sprintf("%02x",szHex[i]);
: Memo->Lines->Add(str2[i]);
: if(i == 13){
: fprintf(fdata," %02x 년 %02x 일\n",str2[3],str2[4]);
: fclose(fdata);
: }
: }
===================================================:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "stdio.h" // 이거 넣었는지요?
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *Str = "";
FILE *fdata;
char *sHex;
char temp;
Byte szHex[64];
String str1,str2[14];;
int i;
fdata = fopen("c:\\jinso0.txt","wt");
// ComPort->ReadStr(str1,Count);
str1="12345678901234";
sHex=str1.c_str();
for (int i=0; i< str1.Length(); i++)
{
szHex[i]=sHex[i];
}
for (int i=0; i< str1.Length(); i++)
{
str2[i].sprintf("%02x",szHex[i]);
Memo1->Lines->Add(str2[i]);
if(i == 13)
{
fprintf(fdata," %02x 년 %02x 일\n",szHex[3],szHex[4]);
// 여기서 스트링을 바로 넣을수 없음 char로 바꾸어야 함
fclose(fdata);
}
}
fclose(fdata);
}
|