|
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}
While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test<br />
Mohsin Ali
|
|
|
|
|
It is because UNICODE is defined. If you want a full understanding, a strongly suggest this article[^].
|
|
|
|
|
It happens because the project is built for UNICODE.
Sudhir Kumar
|
|
|
|
|
Then how can I change...
I mean what I have to do in order to remove this error..
Mohsin Ali
|
|
|
|
|
Use generic text mappings instead of using char arrays. This way if you want to enable UNICODE later on, your program will support it.
|
|
|
|
|
Sorry but I will complain about the answering style of some people.
For example in this question it is obvious that he is a newbie and facing a simple problem. But look at the answers to that simple question.
Its because you are in UNICODE...... is this the answer?
Think about the person expecting a solution : so what? What am I supposed to do? Where should I read?
Would not it be better if you answer it in such a way. (like the way toxcct did for example)
It's because of ......, You should try a code like ......, For more info you can read .... web page
At the top of the forum there is a default subject "How to get an answer to your question" and I think there should be another one "HOW TO ANSWER A QUESTION".
|
|
|
|
|
zafersavas wrote: Its because you are in UNICODE...... is this the answer?
Think about the person expecting a solution : so what? What am I supposed to do? Where should I read?
That would be a good enough clue for most. At this point, the OP simply needs to do this.
"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
|
|
|
|
|
In build toolbar select Win32 Release or Win32 debug.
Sudhir Kumar
|
|
|
|
|
Use of this MessageBox(NULL, _T("This is my first windows program\n Author: Mohsin"), _T("Virtual University"), ...
|
|
|
|
|
Did you got any success with these replyes.
Sudhir Kumar
|
|
|
|
|
change you code into the following. and in a general mean, always use _T() around you literal strings to avoid to matter whether Unicode is defined or not :
#include "stdafx.h"
#include "windows.h"
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MessageBox(
NULL,
<code>_T(</code>"This is my first windows program\n Author: Mohsin"<code>)</code>,
<code>_T(</code>"Virtual University"<code>)</code>,
MB_OK|MB_ICONINFORMATION);
}
|
|
|
|
|
What is the difference b/w Unions and Structures...
Mohsin Ali
|
|
|
|
|
Basically the members of a union share the same memory address (while the members of a struct have distinct memory addresses).
The above implies, for instance:
union MyUnion
{
int i;
float f;
};
struct MyStruct
{
int i;
float f;
};
void main()
{
MyUnion u;
MyStruct s;
u.i = 5;
s.i = 5;
}
and, conceptually, sizeof(MyStruct)=sizeof(int)+sizeof(float) while sizeof(MyUnion)= max(sizeof(int), sizeof(float))
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
|
|
|
|
|
With unions all members start at the same base address so they overlap. With structures, the members are "stacked", i.e. each one starts in the byte after the previous one ends.
|
|
|
|
|
Alan Balkany wrote: each one starts in the byte after the previous one ends.
Too specific to be the right answer for this newbie. One poster said "conceptually" the sizes of the members sum, which is correct *CONCEPTUALLY*.
We should probably point out to the original poster that in a structure, the compiler is free to add padding after ANY member (including the last member) to insure the members align correctly. That is, a structure may contain unused bytes that are there only for alignment.
struct example{
char c;
long l;
};
printf( "sizeof(example) = %d", sizeof(example) );
In most compilers, this will NOT print "sizeof(example) = 5" as might be expected, since the compiler must put padding after c to insure that l aligns properly. In most modern compilers this will likely print "sizeof(example) = 8".
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
question before answering : did you bother searching the web/docs/msdn/google/whatever before asking that dumb question asked and answered tons of times ?
the difference between unions and structures (and classes if in C++) is that all the members of the union share the same memory address. in other words, it means that they all start at the same address, and them, it also means that the size of the union equals the size of its largest member.
so, the other question which usually comes after such an answer is : "but what can it be used for, then ?".
good question Sherlock.
in fact, it's not used much in everyday programming, especially in management applications.
I used to use it when I was coding for hardware, when some component had to share the same physical address. so to represent such a material in the software, a union was exactly what was needed.
|
|
|
|
|
I think you are new to c++ so I suggest to see www.cplusplus.com and on that site you can see different union and other helpful info.
|
|
|
|
|
|
It was optional no coercion because I didnt use of link for that site.
|
|
|
|
|
While structure enables us treat a number of different variables stored at different in memory , a union enables us to treat the same space in memory as a number of different variables. That is a Union offers a way for a section of memory to be treated as a variable of one type on one occasion and as a different variable of a different type on another occasion.
Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members.
Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members.
Example:
union exforsys_t {
char c;
int i;
float f;
} exforsys;
Defines three elements:
exforsys.c
exforsys.i
exforsys.f
Each one with a different data type. Since all of them are referring to the same location in memory, the modification of one of the elements will affect the value of all of them. We cannot store different values in them independent from each other.
Sudhir Kumar
|
|
|
|
|
i am looking for unix file system emulator ...
can you let me know where can i find this?
hi
|
|
|
|
|
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
|
|
|
|
|
Unix systems are proprietary, so, you can't emulate, just can install them on the single hardwares they support.
but maybe you want a linux instead ?
if so, why don't you give a virtual machine a try ?
VMWare is really worth it !
|
|
|
|
|
Did you check VMWare supports Vista 64bit,Virtual Pc doesnt support 64bit but for 32bit it doesnt problem.
|
|
|
|
|
dunno. but i guess it also depends of the hardware of the VM host...
|
|
|
|