|
Here length of the sendbuf is 21. send() function returns the number of bytes it is sended. thats why the value 21. recv() function returns the number of bytes received.
|
|
|
|
|
This is a simple socket communication program. here send() functions sends the data. and it retuns the number of bytes sended. in this length of the string sendbuf is 21. recv() function returns number of bytes received.
|
|
|
|
|
hello, i was wondering if there is an equivalent of the c# feature "properties" in c++. i.e., the client sees it as a variable, but methods are called to access it. You should understand from this c# sample:
<br />
namespace MyApp {<br />
public class TestClass {<br />
private int _item;<br />
<br />
TestClass(int tmp) {<br />
_item = tmp;<br />
}<br />
<br />
public int data {<br />
get {return _item;}<br />
set {_item = value;}
}<br />
<br />
static void Main() {<br />
TestClass x = new TestClass(17);<br />
int res = TestClass.data;
<br />
TestClass.data = 42;<br />
res = TestClass.data;
}<br />
}<br />
}
any equivalient in c++ ?
|
|
|
|
|
No. Properties do not exist in C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
visual studio only supports monochrome, 16-colors and 256-colors icons. how can I attach a 32-bit insolved icon?
|
|
|
|
|
|
|
i guess you are using Visual Studio 6.
you can import into your resources your 32-bits icon but won't be able to open it within VS6. VS7.1 allows you to, however...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I wonder if anyone have an idea how to make an directx overlay (or however its called). I mean something like xfire or TS has, when you run a game, and some1 sends you a message there is a small box drawn in the game from xfire. You know how to do It ? any help appreciated
|
|
|
|
|
Please check the following snippet of code where I have used
AddStore() to add a pst file to a profile. This works in some pcs
while in others it fails with "Outlook faled to add the personal store
to this session". Any ideas?
<br />
_Application olApplication;<br />
_NameSpace olNameSpace;<br />
COleException e;<br />
if(!olApplication.CreateDispatch("Outlook.Application", &e)) {<br />
CString str;<br />
str.Format("CreateDispatch() failed w/error 0x%08lx", e.m_sc);<br />
AfxMessageBox(str, MB_SETFOREGROUND);<br />
}<br />
else {<br />
<br />
olNameSpace = olApplication.GetNamespace("MAPI");<br />
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);<br />
olNameSpace2.Logon(covOptional2, covOptional2, covOptional2,<br />
covOptional2);<br />
}<br />
olNameSpace.AddStore(COleVariant(strDestinyPstPath));<br />
Thanks.
Best Regards,
kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
|
|
|
|
|
Before delving into hex numbers and memory addresses, does anyone have any advice on using "#define new DEBUG_NEW" as an option in DEBUG in VS2003 Standard Edition?
I have the following switches on (/MDd, _DEBUG, /ZI) but as far as I can tell the compiler is not loading the debug library cos it comes up with the following "error C2665: 'operator new' : none of the 5 overloads can convert parameter 1 from type 'const char [71]'" in the "xmemory" file.
I assume this is because the compiler has translated the macro as a string and not a bunch of debug expressions. Is that the correct diagnosis?
What should I change in the project settings to get this to work?
TIA
PS Obviously, the point to all of this is hunting down memory allocations using "new".
|
|
|
|
|
Hello,
I think that you use the DEBUG_NEW macro without including the proper headers. You arn't using MFC are you? See here[^] for more details on DEBUG_NEW
The above method is very basic in detecting memory leaks. If you need good support for the leaks, I can suggest Visual Leak Detector[^] as an excellent open source tool. It worked for me in some of my projects.
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hi, is there anyway in C++ that I could get the size of a simple type array?
I'm trying to pass an array to a function without passing the size of the array..
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
not in general.
if you know the arrays are always allocated with malloc, calloc or realloc, you can use _msize to get the allocated size, then divide by the type size. but that's a giant hack and is very likely to lead to disaster (ex. if someone passes an array that was created on the stack or via new)
it's best to just pass the array size, or use a dynamic container like std::vector.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris Losinger wrote:
but that's a giant hack and is an very likely to lead to disaster (ex. if someone passes an array that was created on the stack or via new)
For that reason, I never could get the infamous countof to work!
#define countof(X) (sizeof(X) / sizeof((X)[0]))
Good to know why it doesn't work..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
That macro only works if the compiler can see X as an array:
#define COUNT_OF(X) (sizeof(X) / sizeof((X)[0]))
void DisplayNumbers(int[6] numbers);
void DisplayNumbers2(int* pNumbers);
void DisplayNumbers3(int* pNumbers, int nSize);
void main()
{
int numbers[] = {1, 2, 3, 5, 8, 13};
int nSize = COUNT_OF(numbers);
DisplayNumbers(numbers);
DisplayNumbers2(numbers);
DisplayNumbers3(numbers, nSize);
}
void DisplayNumbers(int[6] numbers)
{
printf("DisplayNumbers shows:\n ");
int nSize = COUNT_OF(numbers);
for (int i = 0; i < nSize; ++i)
printf("%d ", numbers[i]);
printf("\n");
}
void DisplayNumbers2(int* pNumbers)
{
printf("DisplayNumbers2 shows:\n ");
int nSize = COUNT_OF(pNumbers);
for (int i = 0; i < nSize; ++i)
printf("%d ", numbers[i]);
printf("\n");
}
void DisplayNumbers3(int* pNumbers, int nSize)
{
printf("DisplayNumbers3 shows:\n ");
for (int i = 0; i < nSize; ++i)
printf("%d ", numbers[i]);
printf("\n");
}
The output for this program would be:
DisplayNumbers shows:
1 2 3 5 8 13
DisplayNumbers2 shows:
1
DisplayNumbers3 shows:
1 2 3 5 8 13
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Chris Losinger wrote:
it's best to just pass the array size, or use a dynamic container like std::vector.
True. Another alternative, which is used sometimes for arrays of pointers, are NULL terminated arrays.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Waleed wrote:
is there anyway in C++ that I could get the size of a simple type array?
no, but you might know the size as you explicitely told the amount of memory needed to build it...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
thanks to all of you, I was thinking about using a special value to end my array as it's posted here...
|
|
|
|
|
Hi,
ive made a combo box which resembles MS' combo box in explorer.exe. only trouble is, when i select an item from the drop down, it doesnt display the icon next to the path. ive added the message OnDrawItem and ive tried overriding DrawItem but that didnt work. Where can i handle the message which will allow me to draw that icon?
Thanks,
Skute
|
|
|
|
|
Hi,
I have to write application to detect Disk configuration.
Is disk type is Basic or Dynamic?
I know Basic disk is supported by all windows versions, but dynamic is supported only by windows 2000, XP Pro, 2003 Server.
I am able to get the OS information but unable to get info for hard disk's.
Can anyone help me?
Thanks,
sanjay
|
|
|
|
|
Amazingly, this code seems to compile without errors in VC6. Are you able to repro this or am I doing something stupid?
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
<code>
CWinApp theApp;
void foo
(CString str)
{
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
<code>
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
printf ("Fatal Error: MFC initialization failed");
return (1);
}
unsigned int x = 1;
foo (x); <code>
foo (1); <code>
return (0);
} /ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I would guess you are seeing an implicit constructor call, probably one of the CString(XCHAR c,int count = 1); variants.
Software Zen: delete this;
|
|
|
|
|
|
VC7.0 and VC7.1 add a macro (ATL_CSTRING_EXPLICIT_CONSTRUCTORS , or something like that) to force compile errors in this case.
Software Zen: delete this;
|
|
|
|