MessageBox()
-
dear all i want to display number what i calculated, my code is the folowing: char buff[100]; MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant. so what happened? thanks a lot
gentleguy
gentleguy wrote:
MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant.
That's because you are wrapping 'number%d' in single quotes! Use double quotes "number %d". By the way this won't work out, try this!
const int SomeNumber = 100 + 200;
char buff[100] = { 0 };
sprintf( buff, "My number is: %d", SomeNumber );
MessageBox( buff );There is a function called CString::Format, if you are interested! And if you are further interested you can have a look at this[^].
Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com
modified on Wednesday, June 18, 2008 12:25 AM
-
dear all i want to display number what i calculated, my code is the folowing: char buff[100]; MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant. so what happened? thanks a lot
gentleguy
are you trying to do something like this?
char buff[100];
sprintf( buff, "number %d", number );
MessageBox( buff );-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts, An Article - Understanding Statepattern
-
dear all i want to display number what i calculated, my code is the folowing: char buff[100]; MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant. so what happened? thanks a lot
gentleguy
Hi, You may use like this also :
int num;
CString op;
op.Format("Number : %d",num);
AfxMessageBox(op);
// or
::MessageBox(0,op,"Title",0);Have Good Luck.. :) :rose:
Jagdish Bhimbha S/W Developer
-
dear all i want to display number what i calculated, my code is the folowing: char buff[100]; MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant. so what happened? thanks a lot
gentleguy
For your strings you must be use of _T(" ") not ' '
-
For your strings you must be use of _T(" ") not ' '
Hamid. wrote:
_T(" ") not ' '
Might be he want to convert character instead of string .... ;P
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
Hi, You may use like this also :
int num;
CString op;
op.Format("Number : %d",num);
AfxMessageBox(op);
// or
::MessageBox(0,op,"Title",0);Have Good Luck.. :) :rose:
Jagdish Bhimbha S/W Developer
who voted you down?? let me square it!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
are you trying to do something like this?
char buff[100];
sprintf( buff, "number %d", number );
MessageBox( buff );-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts, An Article - Understanding Statepattern
Sarath. wrote:
char buff[100];
After working in painstaking conversion of MBCS code to UNICODE. Now, i prefer TCHAR instead of char
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
dear all i want to display number what i calculated, my code is the folowing: char buff[100]; MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant. so what happened? thanks a lot
gentleguy
Good
C
tutorial needed. Hint: string literals must be enclosed by double quotes. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Hamid. wrote:
_T(" ") not ' '
Might be he want to convert character instead of string .... ;P
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
So I must be modify my reply. ;)
-
So I must be modify my reply. ;)
No it will work :) don't worry!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
Good
C
tutorial needed. Hint: string literals must be enclosed by double quotes. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
Good C tutorial needed. Hint: string literals must be enclosed by double quotes.
:) would refer him/her for good C book :)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
dear all i want to display number what i calculated, my code is the folowing: char buff[100]; MessageBox(buff,'number%d'); but compiler showed error: error C2015: too many characters in constant. so what happened? thanks a lot
gentleguy
gentleguy wrote:
MessageBox(buff,'number%d');
What in the world is this? :confused: The documentation plainly shows that
MessageBox()
expects four arguments."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne