|
Does anyone know if the new mysql libraries can be called from the old old vc6 (on windows xp)?
thanks!
|
|
|
|
|
Yes, they perfectly work togheter ... swend me an email, and I'll send to you a test application ...
|
|
|
|
|
If I assign a string to a variable.
char* t = "Hello World!";
Doesn't this string get a fixed array with a null terminator at the end?
|
|
|
|
|
Yes. Take a look at it in the debugger if you are not sure.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
wcscat_s keeps throwing an error that the string isn't null terminated! :S
|
|
|
|
|
Are you sure it doesn't throw an exception, because the memory provided in strDestination argument is read-only?
|
|
|
|
|
Fareed Rizkalla wrote: wcscat_s keeps throwing an error that the string isn't null terminated!
Yes, I'm not surprised since you are sending it a char* (i.e. ASCII string) but wcscat_s() expects Unicode.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
No. It assigns a pointer to a fixed null-terinated string, there is a slight difference between arrays and pointers. A writable block of memory is not allocated and you should get a compiler warning because of the unsafe conversion... change the code to:
const char* t = "Hello World!";
Hope this helps
|
|
|
|
|
Moak wrote: a pointer to a fixed null-terinated string,
Which is simply an array of characters.
Moak wrote: there is a slight difference between arrays and pointers.
I would say there is a huge difference.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
every literal string gets a NULL appended automatically by the compiler.
However there are 8-bit and 16-bit characters and strings, and you can't just mix them.
If you use wcscat_s, you want wide char strings, the example in MSDN is:
wchar_t wszStr[] = L"1a1g";
|
|
|
|
|
Hello. I created a new icon in the resource view called "IDI_OBJECT_GLOBAL_VAR". In my "View" cpp, I added the icon to my HICON ( along with a bunch of other icons that work) using the following:
hIcon[ICON_INDEX_OBJ_GLOBAL_VAR] = AfxGetApp()->LoadIcon(IDI_OBJECT_GLOBAL_VAR);
This is then added to a tree list :
for( GUShort index = 0;
index < ICON_INDEX_MAXIMUM;
index++ )
{
m_TreeImageList.Add( hIcon[ index ] );
}
GetTreeCtrl().SetImageList( &m_TreeImageList, TVSIL_NORMAL );
When I go to insert an item with the icon, I use the following:
hNewItem = GetTreeCtrl().InsertItem( label,
ICON_INDEX_OBJ_GLOBAL_VAR,
ICON_INDEX_OBJ_GLOBAL_VAR,
parentTreeItem,
hInsertAfter );
The item itself is placed in the tree, but the icon NEVER displays. It's just blank. Any help on this would be appreciated. Thanks!
|
|
|
|
|
Have you checked the return values of LoadIcon and Add? Since you want to use your indexes as above, I suggest you put in an index check.
for( GUShort index = 0;
index < ICON_INDEX_MAXIMUM;
index++ )
{
VERIFY(m_TreeImageList.Add( hIcon[ index ] ) == index);
}
Who knows? You might be surprised!
(The point is, if any of your icons fail to be added, the indexes are screwed up)
|
|
|
|
|
Hi I have strings like
GROUP23
TREND12
GRAPH120
GRAPH01
From this i have to extract the numbers only like 23,12,120,01...
I tried atoi(),but it returns 0.
I tried Right(),
int iPanNo;
CString sNo;
CString sName = "GROUP23";
sNo = sName.Right(2);
iPanNo = atoi(sNo);
The above code works fine and it returns '23'.
But it fails for GRAPH120.For this it returns 20 not 120.
How can i do that?
Anu
|
|
|
|
|
You need to parse your string into alpha and numeric portions and then apply the conversion on the numeric portion. Take a look at the methods of CString() to see if there is a builtin that will do it for you, or use something like isdigit()[^]. The rest should be easy.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thank you.I coded like
for (int i = 0; i < sNo.GetLength(); i++)
{
Number = sNo.GetAt(i);
if(isdigit(Number))
res += Number;
}
And it works.
Thanks.
Anu
|
|
|
|
|
compare each element of this string to the numeric range '0' to '9', if it's in the range, record it.
|
|
|
|
|
Which is exactly what I already said.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Here is something you can try.
You want only the numerals in the string and they appear after the alphabets.
First you could use CStringT::SpanExcluding to extract only the alphabets in the string.
CString sToken = sName.SpanExcluding(L"0123456789");
Next extract the characters after the length of the alphabets using CStringT::Mid .
sNo = sName.Mid(sToken.GetLength());
|
|
|
|
|
I can see a couple of approaches here. The first way would be to pile your characters in a std::string, use find_first_of to locate where the digits and then use std::stringstream to convert from the digits to a number. That's a bit clunky though.
You could go straight to using a std::stringstream, pile the characters in there and then peak at each character extracting non-digits. Once you hit a digit you could just extract the number.
Cheers,
Ash
PS: If you're stuck using CString then use Superman's idea above
|
|
|
|
|
Anu_Bala wrote: Hi I have strings like
GROUP23
TREND12
GRAPH120
GRAPH01
From this i have to extract the numbers only like 23,12,120,01...
I tried atoi(),but it returns 0.
I tried Right(),
int iPanNo;
CString sNo;
CString sName = "GROUP23";
sNo = sName.Right(2);
iPanNo = atoi(sNo);
The above code works fine and it returns '23'.
But it fails for GRAPH120.For this it returns 20 not 120.
How can i do that?
Didn't it occur to you that you would have to write some kind of crude loop to do that, at the least? Don't post such lazy assed efforts just to avoid scathing comments. These kinds of posts are far worse.
|
|
|
|
|
I think your comments are a tad harsh, particularly your choice of language.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
int begin = sName.FindOneOf("0123456789");
if (begin == -1)
{
}
iPanNo = atoi((LPCSTR)s + begin);
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
[My articles]
|
|
|
|
|
Read from right - to - left.
Check if digit and set position for the left most digit.
Deduct position from length and then you can get the length of your string.
|
|
|
|
|
If you're reading from right to left, you could as well perform the conversion yourself as you pass over each digit.
|
|
|
|
|
Hi All,
I am having a tabbed dialog and all the pages contains several controls. After clicking to any control (say a radio button) if I press escape button on my keyboard the entire page became blank.
Please any one put some light on this. Thanks in advance.
Regrads,
Sandip
|
|
|
|