|
Hi, All!
=======
Is there any way for me to create an operator.
For example, like the 'new' operator:
Instead of: x= new int[5];
It will be: x= MyNew int[5];
NOT : x= MyNew(sizeof(int)*5) ;
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
do a google search on "override operator new". i got 4900 hits. at least the first three pages all looked relevant.
-c
POKE 808,234
|
|
|
|
|
Look up operator new on MSDN.
Michael
|
|
|
|
|
|
I have a program where I need to replace the Alphabet value to numers.
Examples:
I have B13 which has to be replace with 1013.
10 is just aplhabet count. I would know the position in the string to replace.
Please help me.
|
|
|
|
|
But "B" isn't the 10th letter.
Describe your problem more.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
If you count the alphabet A-woud be 10, B- 20,
C-30 ....Z-26
So I have a string where mixed value:letters and numbers.
I need to replace the value of letter with applicable numbers. The string len is different every time.
Thanks.
I tryed your code with my string Modifier and it's not working. Can you tell me why?:
for (i=0; i < strlen(Modifier); i++)
{
ch = Modifier.GetAt(i);
switch (ch)
{
case 'A':
str.Delete(i);
str.Insert(i,"10");
break;
case 'B':
str.Delete(i);
str.Insert(i,"20");
}
}
|
|
|
|
|
A is 01, not 10. Otherwise, A and J have the same value.
Having said that, I would do this by building a second string, otherwise it gets too messy, because you're inserting two chars in the place of one and need to track that in terms of GetAt(). For example if I have "ABC" and I GetAt(0) and replace it, I end up with the string "01BC". If I then iterate through the loop I GetAt(1), I will get back '1', NOT 'B'.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I think he wants to replace all letters in a string with two-character numeric representations.
Assuming a CString is being used:
#include <ctype.h>
CString sText = "A big lazy dog";
CString sResult = "";
CString sTemp = "";
int nLen = sText.GetLength();
sText.MakeUpper();
for (int i = 0; i < nLen; i++)
{
char cCurr = sText.GetAt(i);
if (isalpha(cCurr))
{
sTemp.Format("%02d", (int)cCurr - 64);
sResult += sTemp;
}
else
{
sResult += CString(cCurr);
}
}
<pre>
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
another "funny" story noone knows to help me - see my mail to rational user-board (hi...)
i got many recommendations:
they speak it is not ccase problem only - i never mentioned it at "normal" disc - do you?
it is ntfs problem - i have fat32
use cc-view at your machine - already is, allways was
try patches and service packs - i have them (i hope good ones): w2000 with sp2, msdev 6.0 with c++ processor pack and service pack 4(a) (by my info sp5 has to have another problems)
do you have any ideas?
thanks
t!
hi
one of similar situations
cc4.1 multisite, patches 13-17, dynamic view stored on w2000 client, nt4 server with vob replicas
msdev (6.0, service pack 4, processor pack) project stored on dynamic view contains view-private or checked-out file
config spec: element * checkedout, element * \main\latest
1. in msdev editor edit the file (programming source)
2. save it
3. hands up for 5 minutes - not necessary execute step 3.
4. run msdev compiler - it creates .obj (view private) .exe/.dll (again not under source control), and few other output files, no omake/winkin/etc. is used
5. hands up for 5 minutes - not necessary execute step 5.
6. try run msdev debugger
-> now (sometimes, not everytime, more often with w2000 than nt4) displays for me absolutely nonsence msdev message about "file was modified outside editor, reload it?"
(view private file, one view user, seems long time no another-user change into file's directory, ...)
are we alone with this situation? what to do with?
thanks
t!
|
|
|
|
|
When I use the open file for outputr function like this:
Open "c:\test.txt" For Output As #1 my program works great.
Now I wan't to make "c:\test.txt" to be \\rww2k001\algemeen\test.txt. When the rww2k001 server is online everything works great, but when I disconnected from the server Visual Basic crashes. Does someone know how error handling or something else works with this function.
|
|
|
|
|
shouldn't this be something like ON ERROR GOTO ??
(admittedly, my VB knowledge is limited to witty remarks... ;~) )
peter
|
|
|
|
|
- I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.)
- Can you show me sample codes about that task?
- Regards,
Maer
|
|
|
|
|
The closest thing to what you want is to use GlobalMemoryStatus[Ex]. Note that in multitasking system the available memory can (and probably will) change between the call to GlobalMemoryStatus and actual allocation - so don't count on reliability of this technique.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
- Thanks, Sowinski pal!
- Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "The information returned by the GlobalMemoryStatus function is volatile.".
I am a newbie of this field. I do not know what means "volatile". Can you show me an example?
- Regards,
Maer
|
|
|
|
|
What 'volatile' implies is that the info returned by GlobalMemoryStatus cannot be guaranteed to be correct. You can try this by making successive calls and putting a Sleep(500) in between. You can be sure that you'll get different information. This is because by the time you get the info the memory status of the system would have changed.
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
- Thanks, Nish pal!
- Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "// There are 150960 total Kbytes of paging file.".
- I do not know what means "paging file". Can you show me an example?
- Regards,
Maer
|
|
|
|
|
There's a tool that comes with VC that can simulate this if you're wanting to test your code under the extreme conditions (which is a very good thing btw).
Todd Smith
|
|
|
|
|
- Thanks, Smith pal!
- Your reply helps a lot. I still have two questions.
- 1. What is the tool? Where can I find it?
- 2. What means "btw"?
- Can you help?
- Regards,
Maer
|
|
|
|
|
Man, this question is a lot harder than it sounds. The quick answer is 2GB if you don't use AWE.
GlobalMemoryStatus is a start, but there are other issues. First would be what is the total number of pages a process is allowed to allocate. Second, even if you could in theory allocate tons and tons of memory, fragmentation of the address space will limit you to the total amount of memory.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
- Thanks, Smith pal!
- Your reply helps a lot. I still have a question. What means "AWE"?
- Can you help?
- Regards,
Maer
|
|
|
|
|
howdy, i'm still learning alot about MFC and some c++ and i have looked through the forms and found answers to my other problems but not this one, so sorry if its been asked before.
might seem simple but i'm have trouble setting text for a subitem in a list control, i have 2 comlumns, name and status i add items under name fine but have tried a few different things to add items under status, any help would be great, thanks
muz
|
|
|
|
|
Use SetItemText(). This example assumes the list control already has an item at index zero.
CListCtrl* pListCtrl = (CListCtrl *) GetDlgItem (IDC_LISTCTRL);
ASSERT (pListCtrl != NULL);
VERIFY (pListCtrl->SetItemText (0, 0, "Ravi Bhavnani"));
VERIFY (pListCtrl->SetItemText (0, 1, "Geek"));
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks for the quick reply, it worked
thanks again
muz.
|
|
|
|
|
I have written a static library with a CDialog divivative in it, and drawn a grid on the dialog, I then wanted to traverse my grid and needed to capture key presses e.g. UP '1' '2', I did this using entries in an accelerator table. I can now capture the key presses, but each key press makes a beep, is there any way to disable this beep?
also is there any way to stop the up,down,left and right keys from changing the currently focused button or component??
cheers!!
Andy
Andy
|
|
|
|