|
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
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
See here.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
so sad it doesn't help
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
try88 wrote:
so sad it doesn't help
Why?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I'm not sure I understand what you want to confirm.
when you click on a tree item, you will have a TVN_SELCHANGED notification ( add an handler for that ), in the handler you will receive the HTREEITEM that is selected.
something like :
void MyTree::OnTreeSelchanged( NMHDR* pNMHDR, LRESULT* pResult )
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM item = pNMTreeView->itemNew.hItem;
}
if you want to check for a "hardcoded" string, CTreeCtrl::GetItemText( ... ) might be what you want to check for.
otherwise, I'm not certain.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
look at this figure:
----------------- 1
--1-------------- 2
---1。1-------- 3
---1。2-------- 4
---1。3-------- 5
--2-------------- 6
---2。1-------- 7
---2。2-------- 8
---2。3-------- 9
you know when i click the item for example item 4 which is"---1。2--------";
the question is how can i know that i clicked the item is item4 not others by code in my function OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) ?
that means how to judge the item clicked is the one i want in code.
your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text.
路漫漫其修远兮,吾将上下而求索。
|
|
|
|
|
try88 wrote:
...how can i know that i clicked the item is item4 not others by code...
By looking at the NMTREEVIEW structure, specifically the itemNew member.
try88 wrote:
your hint using GetItemText( ... ) maybe bot work when my item text is put dynamically,for you even not konw the exact text.
What? How else are you going to add text if not dynamically? Tree controls are not populated at design/compile time. If an item has text, that text can be retrieved via GetItemText() . Have you looked at the documentation for how this function works?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|