|
How silly.
So that must be wrong too.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
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]
|
|
|
|
|
The code (albeit not beautiful) is correct.
With szLogBuf[512]={0}; you actually initialize the whole buffer with 0 (that is '\0').
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]
|
|
|
|
|
Then what is the best way to clear the buffer initially?
|
|
|
|
|
Since you are dealing with strings there isn't a need to clear the whole buffer.
char x[100] = { 0 };
internally calls memset. In your case it's a waste of (7 or so not including the loop inside memset) CPU cycles.
char x[100];
x[0] = 0;
initially creates an empty string. Just 1 CPU cycle.
But then, calling functions like strcpy and sprintf don't require the buffer to be empty whereas strcat NEEDS a string (empty or otherwise) to append to.
Waldermort
|
|
|
|
|
whereas strcat NEEDS a string (empty or otherwise) to append to.
so I'll have to memset everything to 0 or initialize everything to 0 right?
|
|
|
|
|
No. When dealing with string buffers you only need to set the first char/wchar/tchar to 0.
char myString[100];
strcat( myString, "Hello World!" );
strcpy( myString, "World!" );
myString[0] = 0;
strcat( myString, "Hello World!" );
The new string is actually 13 chars because there is a 0 at the end.
On another note. You shouldn't be using those string functions. There are safer versions available:
strcpy_s( myString, 100, "Hello World!" );
These check to make sure the buffer is large enough for the string
Also, you might want to read up on TCHAR and the unicode/ansi string functions
TCHAR myString[100];<br />
_tcscpy_s( myString, 100, _T("Hello World!");
Waldermort
|
|
|
|
|
CPallini wrote: The code ... is correct.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
It isn't wrong. It isn't elegant nor optimal, but not wrong. I think this is a great achievement, after all.
(It's a subliminal suggestion for you: could you please hire the OP?)
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]
|
|
|
|
|
CPallini wrote: It isn't elegant
true.
CPallini wrote: nor optimal
true.
CPallini wrote: not wrong
false. see my reply to OP.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
See my reply[^].
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]
|
|
|
|
|
On most 32 bit systems bit 1 and 2 are not used in an address. This allows the CAS algorithm to test an address and also test a flag (very useful for non blocking linked lists).
However on a 64 bit system those 2 bit are in use.
After doing some googling I have found that AMD64 and IA64 use 48 bits. AMD plans to extend that 52 bits.
So my question is, Am I safe to use bit 1 of a 64 bit address, if so will it be portable?
Waldermort
|
|
|
|
|
What exactly do you want to ask ?
Is it processor architecture ?
Is it C, or C++, or C# ?
Is it Win32 / Win64 ?
Is it about pointers ?
If you (in C/C++/C#) have a BYTE array, then ALL lower bits of an address WILL be used; ohterwise you wouldn't be able to do a bulk read or write from a binary file.
Of course, if you do so, you will earn a lot of additional CPU cycles due to misalignment of addresses to WORD / DWORD boundaries, but as cores are so fast now, it doesn't really matters
|
|
|
|
|
Hi,
I need information on socket programming and need to develop an application which communicates with each other as server socket and client socket..
Can any one help me out regarding this...?
Thanks
John.
|
|
|
|
|
Google[^] is your friend and has a lot of information. And this[^] is a good lecture as well
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
I use VC 6.
Some classes can not be viewed on Class-View, but header files of those invisible classes are all added to project, which can be found on File-View.
If I slightly modify header files of those invisible classes, they appear on Class-View.
If I reopen the project, those classes are still invisible on Class-View.
How to fix the bug?
|
|
|
|
|
not exactly sure what would cause this specifically, but sometimes you get weird behavior if you don't include files properly and/or don't properly use header guards
|
|
|
|
|
I had this problem too , and I solve it in that way : I edit something in header files ( of class who is hidden in Class View ) , then Ctrl + S and they will show up in Class View .
|
|
|
|
|
Delete your .ncb file (or rename it) - VS6 will re-create it.
|
|
|
|
|
If I remember well, deleting the .clw file makes the trick: the IDE builds a new, correct one (anyway, before trying, please do a backup of the original .clw file).
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]
|
|
|
|
|
Close the workspace and Delete *.clw and *.ncb files from your workspace.
After open the project select the classwizard. now it will say class file does not exist and you can select all your *.cpp and *.h files from the list and recreate the clw file.
|
|
|
|
|
Delete VC6 and move on to VC10 everything would be alright.
|
|
|
|
|
hi
i doing project on the hiding the folder in windows OS that should not be visible when click the check show hidden .....
i mean making the folder totally invisible like the folder lock 6.5 will hide ...
i am not getting the idea how they had done ...
help me out from this
thanking you....
|
|
|
|
|
Don't know Folder Lock (any version), but have a look at File System Filder Drivers[^] and File System Filter Driver Tutorial[^], maybe those are pointing at the right direction.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|