|
안녕하세요.
hongfox입니다.
위 내용을 가지고 Test했는데 이상이 없습니다.
Test한 내용입니다.
<<< a.cpp >>>
#include <vcl.h>
#pragma hdrstop
#include "a.h"
#include "b.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TReportForm *ReportForm;
//---------------------------------------------------------------------------
__fastcall TReportForm::TReportForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TReportForm::FormClose(TObject *Sender, TCloseAction &Action)
{
Action = caFree;
}
//---------------------------------------------------------------------------
void __fastcall TReportForm::Exe_BtnClick(TObject *Sender)
{
int result[10]; // 위 내용에 없는 변수값을 이곳에다 선언해 주고 시작했습니다.
bool errorCheckFlag;
// ValueCheck();
errorCheckFlag = false; //
if(errorCheckFlag)
{
errorCheckFlag = false;
Hp_label1->Caption = "입력된 값에 오류가 있습니다.";
}
else
{
// ReportPrintProcessor(index, result, status_flag, mode_flag); <====== 이렇게~~불러
result[0] = result[1] = result[2] = result[3] = result[4] = 0;
result[5] = result[6] = 0;
// result[7] = result[8] = result[9] = 0;
result[7] = result[8] = result[9] = 1;
ReportPrintProcessor(0, &result[0], 1, 1);
Hp_label1->Caption = " ";
}
}
<<< b.cpp >>>
#include <vcl.h>
#pragma hdrstop
#include "b.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
AnsiString processName;
AnsiString arguments;
void ReportPrintProcessor(int index, int *result, int status_flag, int mode_flag)
{
switch(index)
{
case 0 :
if( result[7] == 0 || result[8] == 0 )
{
ShowMessage("Arguments Error!!!");
return;
}
processName = "IntNameRep";
arguments += " " + IntToStr(result[7]) + " " + IntToStr(result[8]);
break;
case 1 :
if( result[7] == 0 || result[8] == 0 || result[9] == 0 )
{
ShowMessage("Arguments Error!!!");
return;
}
processName = "IntSplitRep";
arguments += " " + IntToStr(result[7]) + " " + IntToStr(result[8]) + " " + IntToStr(result[9]);
break;
// . . . . . 중간생략 . . . .
}
}
지나가는 사람 님이 쓰신 글 :
:
: *result와 result[]는 같습니다.
:
:
: 개박살.U&I 님이 쓰신 글 :
: :
: : 안녕하세요? 개박살입니다.
: :
: : 이건 Turbo-c/Borland C++에 해당하는 내용이군요 ^^;
: :
: : 배열과 포인터에 대한 이해가 부족하셔서 나는 에러입니다.
: :
: : int result[10]; 이라는 것은 배열입니다....
: :
: : 그러나, result를 함수의 인자로 넘기려면 포인터를 써야하죠
: :
: : result라는 이름 자체가 &result[0] 이랑 같은 내용이죠
: :
: : 즉, b.cpp에 함수를 void check(int *result) 로바꾸어 주시면 됩니다.
: :
: : 그리고 함수안에서는 배열과 똑같이 쓰시면 되죠
: :
: : void check(int *result)
: : {
: : result[0] = 0;
: : }
: :
: : 이런식으로 되다는 말입니다
: :
: : 그럼 참고하세요~
: :
: : charity 님이 쓰신 글 :
: : : a.cpp 화일에서...
: : :
: : : int result[10]; 이걸 잡고 각각의 값을 넣어주었습니다..
: : :
: : :
: : : 이를 b.cpp 화일에 있는 check(result) 를 불러서~~
: : :
: : : 거기서 일을 처리하구 싶습니다..
: : :
: : : 그래서~~~
: : :
: : :
: : : a.cpp 라는 화일에 헤더화일을 #include "b.h"를 선언해주고~
: : : check(result);를 넣었습니다..
: : :
: : : 글구~ b.cpp 화일에다가는~~~
: : : 먼저 헤더 화일에 void check(int[]) 이렇게 놔두고..
: : :
: : : b.cpp 화일에 void check(int result[]) 이런 함수를 놔두었더니.. 에러가 나네요~~
: : :
: : : ^^; 뭔가가 잘못된거 같기는 한데.. 뭐가 잘못된건가여~~ T_T
: : :
: : :
: : : byte로 할때는 된거 같은데....
|