Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i hav written a code in header file under a button in visual studio 2005(windows form application)but i want to include this code under .cpp file.but if i copy this code directly into .cpp file it gives error.may be i hav to define the function prototype in header file and the function definition in cpp.can u pls send me some example to do this for both header and cpp file.pls help me..its urgent
the following is just a little part of the code in .h file:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

array<Char>^arr;
arr = richTextBox1->Text->ToCharArray();
int imgsize,imgsize1,ht,wdth;
ht=pictureBox1->Image->Height;
wdth=pictureBox1->Image->Width;
imgsize=ht*wdth;
imgsize1=imgsize/8;
int len=richTextBox1->Text->Length;
//array declaration
array< array< int >^ >^ messag= gcnew array< array< int >^ >(imgsize1);
for(int i=0;i<imgsize1;i++)
{ messag[i] = gcnew array<int>(8);
}

int length =richTextBox1->Text->Length;
embed1::Class1 c;
messag = c.chartobin(arr,length,imgsize1); //converts text frm textBox to binary;

//Printing to a file//
FILE *fp1;
if((fp1=fopen("message.txt","wb"))==NULL)
{ printf("\a\nError while creating a file.\nSystem is exiting....");
exit(0);
}
for (int j = 0; j < messag->Length; j++)
{ for(int i=0;i<messag[j]->Length;i++)
{ fprintf(fp1,"%d",messag[j][i]);
}
fprintf(fp1," ");}
Posted
Updated 30-Mar-10 21:11pm
v3

1 solution

You will need the function prototype in a header file and the function definition in cpp file. Make sure they match and both files are included.

What is the error that you are getting? :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900