BJA is right.
fout is a file pointer or stream. The textbox is looking for a string.
Create a character array to hold all the text.
Add each outchar character to the character array.
When you're done reading the file, append '\0' to your character array to make it a null terminated string.
Use your new string in SetCtrlVal, not the file pointer for a closed file.
Make another correction to SetCtrlVal: the first parameter to SetCtrlVal is the panel handle returned by LoadPanel, not the panel constant. See the function panel help or on-line help for SetrCtrlVal. If your new string is called outString, here's the SetCtrlVal call.
SetCtrlVal(panelHandle, PANEL_TEXTBOX, outString);
Why are you casting inchar[0] as a char when you already declared char inchar[2]?
Since you're subtracting 128, it wuould actually be better if you declared inchar and outchar unsigned char.
You may want to do some error checking:
Did fread read a character? Note: using fread and feof the way you do, you call fread one more time after reading the last character in the file.
Is the file size greater than expected (the size of outString)?
Is inchar < 128?
Your code may end up something like this.
#define MY_MAX_FILE_LENGTH 100 // whatever length
unsigned char inchar[2], outchar[2];
char outString[MY_MAX_FILE_LENGTH];
int i;
// fopen stuff
//...
i=0;
while(!feof(FH))
{
if (fread(inchar,1,1,FH) > 0)
{
// a character was read
if (inchar[0] >= 128)
{
outchar[0] = (inchar[0] - 128);
fwrite(outchar,1,1,fout);
if (i < MY_MAX_FILE_LENGTH)
outString[i++] = outchar[0];
else
{
//handle the error
}
}
else
{
//handle the error
}
}
}
outString[i] = '\0';
fclose(FH);
fclos
e(fout);
SetCtrlVal (panelHandle, PANEL_TEXTBOX, outString);