|
좋은 답변 감사드립니다......
항상 좋은 답변 달아 주시는거 감사하게 생각하고 있습니다.^^
금목암 님이 쓰신 글 :
: sunje 님이 쓰신 글 :
: : //---------------------------------------------------------------------------
: :
: : #include <vcl.h>
: : #pragma hdrstop
: :
: : #include <stdio.h>
: :
: : #include "Unit1.h"
: : //---------------------------------------------------------------------------
: : #pragma package(smart_init)
: : #pragma resource "*.dfm"
: : TForm1 *Form1;
: : //---------------------------------------------------------------------------
: : __fastcall TForm1::TForm1(TComponent* Owner)
: : : TForm(Owner)
: : {
: :
: : Cont=1;
: : Bar=1;
: : }
: : //---------------------------------------------------------------------------
: :
: : void __fastcall TForm1::Timer1Timer(TObject *Sender)
: : {
: : // int Cont; ->헤더파일
: : // int Bar; ->헤더파일
: : AnsiString str, str2, str3;
: :
: : if( Cont <=9 )
: : {
: : str.printf("C0""%d"",B3,REQ,""%d",Cont,Bar);
: :
: : char packet[] = "";
: : int i;
: : int size = 0;
: : char cksum = 0;
: :
: : sprintf(packet, "%s", str);
: :
: : while(packet[size] !='\0')
: : printf("%d",size++);
: :
: : printf("\n");
: :
: : for(i = 0 ; i < size ; i++)
: : {
: : if(i == 0)
: : cksum = packet[i];
: : else
: : cksum^= packet[i];
: : }
: :
: : str3.printf("%X",cksum);
: :
: : Edit4->Text = str3;
: :
: : str2.printf("$C0""%d"",B3,REQ,""%d""*""%x""\n ",Cont,Bar,cksum);
: :
: : Memo1->Lines->Add( str2 );
: :
: : Bar++;
: :
: : if (Bar>=9 )
: : {
: : Cont++;
: : Bar=1;
: : }
: : }
: : }
: : //---------------------------------------------------------------------------
: :
: : 들어온 데이터에 대해 체크섬을 만들려고 하는데요.
: : 위의 프로그램을 실행하면 아래 부분부터 메세지 창과 함께 프로그램이 멈추네요...
: :
: : Edit4->Text = str3;
: :
: : str2.printf("$C0""%d"",B3,REQ,""%d""*""%x""\n ",Cont,Bar,cksum);
: :
: : Memo1->Lines->Add( str2 );
: :
: : 이유를 잘 모르겠습니다.
: : 고수님들의 조언 부탁드립니다.......
:
:
: 요기 두부분을 타이머 밖에서 쓰세요
: Edit4->Text = str3;
: Memo1->Lines->Add( str2 );
|