Why do I get this error:
78 wnd_mng.cpp
initialization to `const char' from `const char *' lacks a cast
87 wnd_mng.cpp
jump to case label
and the same thing again??
This is a discussion on Error with LB_ADDSTRING.. within the Windows Programming forums, part of the Platform Specific Boards category; Why do I get this error: 78 wnd_mng.cpp initialization to `const char' from `const char *' lacks a cast 87 ...
Why do I get this error:
78 wnd_mng.cpp
initialization to `const char' from `const char *' lacks a cast
87 wnd_mng.cpp
jump to case label
and the same thing again??
Can you illustrate your problem with some relevant code?
Greetings.
I guess your code looks something like this:
switch(something)
{
case x:
const char A = "text";
...
break;
case y:
...
break;
}
To solve the problems, put brackets around the 'case x' statements. Also add a '*' before 'A' in i order to make it a pointer. Storing a string pointer into a signed byte isn't good.
This is how if should look like:
switch(something)
{
case x:
{
const char *A = "text";
...
}
break;
case y:
...
break;
}
// Gliptic
It seems you are trying to define which text is stored into A in different cases: In this case I think you can't use a const value.
(a const value is loaded into process memory space as soon as your program is loaded in memory, and this piece of memory is blocked against writing while your program runs)
If I were you I would try to modify the code as follows:
int iLen = 0;
char * A = NULL ;
switch(something)
{
case x:
iLen = strlen("some text") + 1;
A = new char[iLen];
strcpy(A,"some text");
//use the value of A
delete [] A;
case y:
iLen = ...
A = new char[iLen];
//...
delete [] A;
//...
}
Greetings.