|
class Base
{
protected:
static int counter;
public:
Base() { counter++; }
};
int Base::counter;
class Derived : Base
{
public:
Derived()
{
counter--;
}
};
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
How can I convert a string to an ASCII value and then store it in an element of a char array? For example, I'd like the 30 to be stored in element[18] of the array. This is what I have. Thanks!
char array[20];
array = "Supernatural";
CString str = "40";
strcpy(array[18],str); error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'
|
|
|
|
|
str.GetBuffer will work!
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
You can't. It's not possible to store a string as an element in a character array. Maybe what you're looking for is an array of char * ?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
yes he can. CString class provides a LPTSTR cast operator...
so using strcpy() is possible as it uses this way 2 char arrays...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
No he can't . It's not possible to store a string as an element in an array of characters. From what I understood, the OP wants to do this
char arr[20] = "Senthil";
arr[5] = "Kumar";
which isn't logically possible.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
oh yes, i did this it like this. i saw (arr + 5) = "Kumar"; which would mean writing from the 5th position in the array.
but ok, you're right, i appology.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes, I do have an array of characters. I need to convert the ASCII value which is currently a string value to an ASCII character. Then store that ASCII character into the 18th element of the array. How do I go about doing that?
|
|
|
|
|
Are you talking about this:
CString str = "40";
array[18] = atoi(str);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
elephantstar wrote:
array = "Supernatural";
What is this, other than a syntax error? If you want array to contain the string literal, use either of:
char array[20] = "Supernatural";
...
char array[20];
strcpy(array, "Supernatural"); elephantstar wrote:
strcpy(array[18],str);
The error message tells you exactly what the problem is. array[18] is a char , but the first parameter of strcpy() is supposed to be a char* .
Why are you using char in such a fashion? If this is an MFC application, use CString . Mixing the two types is seldom necessary.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I want to store the value of CString str into the array.
vtValue.ChangeType(VT_BSTR);
str = (LPCSTR)((_bstr_t)vtValue.bstrVal);
Then I want to store the exact same data type into array[18].
Yes, it is an MFC application. I'm using char so that I can manipulate the data in each element easily.
|
|
|
|
|
elephantstar wrote:
vtValue.ChangeType(VT_BSTR);
str = (LPCSTR)((_bstr_t)vtValue.bstrVal);
What's with all of the BSTR and VARIANT stuff? Is this part of the original problem?
elephantstar wrote:
I'm using char so that I can manipulate the data in each element easily.
CString objects can be manipulated just as easily.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Sorry, I should have included the rest of the code. I'm using ADO to query some values.
CString str, str2;
_variant_t vtValue;
vtValue = t_Rec->Fields->GetItem("NAME")->GetValue();
vtValue.ChangeType(VT_BSTR);
str = (LPCSTR)((_bstr_t)vtValue.bstrVal);
Instead of using char array[20], you're suggesting I just work with CString then. But if I do use CString, the following code fails. What am I doing wrong? Thanks.
vtValue = t_Rec->Fields->GetItem("NUMBER")->GetValue();
vtValue.ChangeType(VT_BSTR);
str2 = (LPTSTR)((_bstr_t)vtValue.bstrVal);
char x;
x = atoi(str2);
str.GetAt(18, str2);
|
|
|
|
|
elephantstar wrote:
str.GetAt(18, str2); ///Debug Assertion Failed
This must be .Net as the CString::GetAt() method that comes with VC++ v6 only takes one parameter.
In any case, what line of what file is firing the assertion?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Nevermind. I went back to using char and it works just fine. Thanks Dave! Your help is always appreciated.
|
|
|
|
|
Hi All,
What is the difference between a simple win32 application and a win32 console application?
Thanks in advance
Preeti9
|
|
|
|
|
the console application is a command line application, no graphical user interface ( GUI ).
the simple win32 can be a console application but it can also be an application that have a GUI.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for your quick reply....Thanks once again
Preeti9
|
|
|
|
|
How can I from my view show only in time either the Date (day/month/year) ,either the time. Not the two Date and time in same time
I learn my self
|
|
|
|
|
Is this what you are asking about:
COleDateTime dateTime;
CString strDate = dateTime.Format("%x");
CString strTime = dateTime.Format("%X");
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
No, I put one an Edit control one my formview or Dialog, and i define a member variable with classwizard like m_date that is type is COleDateTime.
When the view or dialog is display, they show date and time together.
I need to show one of them , either date or date only. What to do
I learn my self
|
|
|
|
|
mikobi wrote:
I need to show one of them , either date or date only.
Ok, so just populate the edit control with m_date.Format() liked I showed.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi
what i mean is that if i clicked the item4 "---1。2--------" ,how to confirm i real did that in code.
----------------- 1
--1-------------- 2
---1。1-------- 3
---1。2-------- 4
---1。3-------- 5
--2-------------- 6
---2。1-------- 7
---2。2-------- 8
---2。3-------- 9
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
Are you talking about the TVN_SELCHANGED notification?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
yes i am ,TVN_SELCHANGED or NM_CLICK
you know the answer? please give a hint
路漫漫其修远兮,吾将上下而求索。
|
|
|
|