message box problem

Hi everyone,
i have a simple question, im not expert with C++ stuff,
the question is, my SW is wearching into a text file for a string, then i need to show that string in a Messagebox, and later i will pass it to FPGA,

the question not related to FPGA, its a simple C++ (i think), here is my code

while(!srcfile.eof()) //here im looking for the string i want
{
getline (srcfile,line);
int offset;
if ((offset = line.find(first, 0)) != string::npos) {
cout << "found '" << first << "' @ offset " << offset << endl;
break;
}
i++ ; //line number
}
MessageDlg("found at line." + i , 0); //here im trying to show the line number in messagebox, BUT i receive this error

[BCC32 Warning] : W8012 Comparing signed and unsigned values
[BCC32 Error] : E2285 Could not find a match for 'MessageDlg(const wchar_t *,int)'

thanks in advance
Last edited on
If you want to output to console, look into std::cout http://www.cplusplus.com/reference/iostream/cout/

If you want some kind of graphical message box, it will depend on your operating system and your choice of graphical user interface library.

Edit: I'm guessing that you're using Borland C++, which does come with some libraries that have a MessageDlg function. The function has the following prototype:

int __fastcall MessageDlg(const AnsiString Message,
TMsgDlgType IconType,
TMsgDlgButtons Buttons,
int HelpContext);

You need to provide a value for each input parameter to use it.

http://www.functionx.com/bcb/topics/msgbox.htm
Last edited on
thanks Moschops,

but im not expert in GUI, you right im using Borland and im working under Win7, if its important somehow

its my first time to use the error message, and i dont know what is the problem,

when i out the parameters to a file, it works fine, but when i use messagebox it give me that silly error

for example when i use that message, and even with this i cant show the 10
int linenum = 10;
MessageBox(0,"MessageText" + linenum, "Titel" ,MB_OK);

i just need to display integer and string variable,
MessageBox takes three parameters. Not four.
int __fastcall MessageBox(const char * Message, const char * Caption, int Flags);from http://www.functionx.com/bcb/topics/msgbox.htm

MessageBox takes three parameters, MessageDlg takes four. You can't just switch MessageBox and MessageDlg around and not change the parameters.

Last edited on
but i used

MessageBox(NULL, thirdchr , "Error", MB_OK); //Works fine with string

and its working, but with the string only,,,, whenever i try to display an integer, it shows blank in the messagbox

MessageBox(NULL, "count: " + int , "Error" , MB_OK); //shows blank message box
Last edited on

And how about if you create the string you want first, and then put it into the MessageBox call?

"count:" is a const* char, so "count:" + int is pointer arithmetic - not string concatentation. Put another way, "some string" + 7 does not give you "some string7"
Last edited on
Topic archived. No new replies allowed.