|
skatzteyp wrote: meaning i get to have an array size of 5+ billion bytes which obviously cannot be contained on an unsigned int variable
You are limited to a theoretical limit of 2GB. Given everything else that needs to fit inside of that address space, you'd be hard pressed to find 1GB of contiguous memory for allocation purposes.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Has anyone figured out how to use it yet? I have VS 6.0 and find it easy to use. I can't seen to find any MFC lib. and where is the Wizard? I have no idea how to begin using VS 2005. What is a "Solution" and what is "CLR"?
A C++ programming language novice, but striving to learn
|
|
|
|
|
I have been using 2005 for about a year now. I had some problems like setting the event initialize on a dialog. I don't know why but usually in 6.0 you can just right click and click on the event to add it, but in 2005 the event is disabled when you are choosing a dialog. Though I like the intellisense in 2005 than 6.0. Though it eats up 10Mb+.
|
|
|
|
|
I'm curious why your using the beta... and where the heck did you find it?
I mean, VS 2008 is past beta at this point
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here's the address:
<a href="http://msdn2.microsoft.com/en-us/evalcenter/bb655864.aspx">http://msdn2.microsoft.com/en-us/evalcenter/bb655864.aspx</a>[<a href="http://msdn2.microsoft.com/en-us/evalcenter/bb655864.aspx" target="_blank" title="New Window">^</a>]
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: http://msdn2.microsoft.com/en-us/evalcenter/bb655864.aspx
Ohhh, that's 2008 Makes much more sense!
I've been using the VS 2008 release candidate for a couple weeks
for full time C++ development.
BTW, here's a CLR Wiki[^]
Starting with Visual Studio .NET 2002, C++ code can be compiled to CLR
code which allows access to the .NET framework.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Glad I'm not the only one thrown by the new interface... I have both installed on my machine. I'm writing a console app right now, so the lack of the neat painter isn't as much of a big deal, but I kept VS 6 in case I want to do that, then I can just bring the app into VS 2005 to do the deep stuff... that's the idea anyway, haven't actually done it yet. Any 'windows' stuff I need to do keeps getting done in VS 6.
Anyone checked out VS 2008 yet to see how they do it?
=->Mocs<-=
|
|
|
|
|
I don't know where to begin!!!!
I openned what I suppose is a projects dialog and it ask for what type (ie, "CLR" .... "General", etc.) I have no idea what it is asking for. Why can't they keep things simple like VS 6.0?
I loaded a previously written sample from MSDN(6.0) and it immediately didn't know any of the "Stdarg.h" headers.
I just don't see where it is at all comparable to VS 6.0.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Hey all,
I wanted to create an SMTP email server in C++. Do you have any recommendations
for nice classes that would help me achieve this ? Or any tutorials ?
Thanks !
-- modified at 5:12 Thursday 1st November, 2007
|
|
|
|
|
Hi all. I have a project that requires me to call bind() for Windows to bind with an address. I went here: http://msdn2.microsoft.com/en-us/library/ms737550.aspx to find out how its used but im a bit confused. It says i need sockaddr() in order to bind. Is that correct? Can someone show me what to do here because im lost. It would be nice if i could see some example code with the bind() function in it. Thanx in advance!
|
|
|
|
|
dellthinker wrote: some example code with the bind() function in it.
Here you go:
hostent * localHost;
char * localIP;
SOCKADDR_IN localAddress;
m_hSocket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_hSocket == INVALID_SOCKET)
{
return false;
}
memset (&localAddress, 0, sizeof (SOCKADDR_IN));
localHost = gethostbyname ("");
localIP = inet_ntoa (*((struct in_addr *) *(localHost->h_addr_list)));
localAddress.sin_addr.s_addr = inet_addr (localIP);
localAddress.sin_family = AF_INET;
localAddress.sin_port = htons (usPort);
if (bind (m_hSocket, (SOCKADDR *) &localAddress, sizeof (SOCKADDR_IN)) == SOCKET_ERROR)
{
closesocket (m_hSocket);
m_hSocket = INVALID_SOCKET;
return false;
}
if (listen (m_hSocket, SOMAXCONN) == SOCKET_ERROR)
{
closesocket (m_hSocket);
m_hSocket = INVALID_SOCKET;
return false;
}
usPort is a variable that indicates the TCP port number this socket is bound to
Judy
|
|
|
|
|
In addition to Judy's excellent reply....
A sockaddr is a generic structure since sockets can be used on
any protocol, not just IP protocols.
Therefore, for IP(4) protocols, a sockaddr_in (socket address internet) structure is used
since it specifically defines a complete IP address.
You can also bind to the address INADDR_ANY if you want to let WinSock pick the adapter
to bind to:
localAddress.sin_addr.s_addr = INADDR_ANY; Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: In addition to Judy's excellent reply....
|
|
|
|
|
I have added <> to the code. My compare function works. I want to ask how to set up the input parameters for compare functions, so that Compare works on 2 different sizes.
-- modified at 12:32 Thursday 1st November, 2007
The following is small sample of the template code I am using.
template <unsigned char sz> class MyStringBase<br />
{<br />
protected:<br />
unsigned char Len;<br />
char Data[sz];<br />
};<br />
<br />
template <unsigned char sz> class MyString : MyStringBase<sz><br />
{<br />
public:<br />
MyString () { Len = 0; Data[Len] = 0}<br />
MyString (const char* src);<br />
bool Compare(MyString??? rhs, int len);<br />
};<br />
<br />
template<unsigned char sz> MyString <sz>::MyString (const char* src)<br />
{<br />
long len = strlen(src);<br />
Len = (unsigned char)((len > sz)? sz: len);<br />
strncpy(Data, src, Len);<br />
}<br />
<br />
template<unsigned char sz> bool MyString <sz>::Compare(MyString??? rhs, int len)<br />
{<br />
if (len<0)<br />
len = Len;<br />
return ((Len==rhs.Len) && (Len<=len) && (strncmp(Data,rhs.Data,len)==0));<br />
}
Compare function has MyString??? which I need to get filled in so I can do the following
MyString<40> a("Test String 1");<br />
MyString<80> b("Testing of String 2 is good") ;<br />
<br />
bool same4 = a.Compare(b,4);
Thank you for your response.
|
|
|
|
|
Please edit your post so that all "<" and ">" symbols and their contents are visible.
Steve
|
|
|
|
|
I would like to say that I might experiment with that, but I would be lying. Your best bet is to use the strings provided by the STL.
Given that and the fact that you are mixing C++ and C (normal - actually), then internally to your class, use ‘strncmp’ to compare a particular number of characters.
Look if you understand basic programming, then you can write 70% of the C library in a week, including non-standard methods.
int compare(char* s, size_t n)
{
int i;
for( i=0; s[i]; ++i )
if( Data[i] != s[i] )
return(Data[i] - s[i]);
return(0);
}
Or something like that.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
template <unsigned char sz> class MyString : MyStringBase<sz>
{
public:
MyString () { Len = 0; Data[Len] = 0}
MyString (const char* src);
template <unsigned char sz>
bool Compare(const MyString<sz2> &rhs, int len);
};
template <unsigned char sz>
template <unsigned char sz2>
inline bool MyString<sz>::Compare(const MyString<sz2> &rhs, int len)
{
if (len<0)
len = Len;
return ((Len==rhs.Len) && (Len<=len) && (strncmp(Data,rhs.Data,len)==0));
}
I think VC6 will have trouble with this code and you'll need to move the definition of Compare into the class (in which case drop the bits in italic).
Steve
|
|
|
|
|
Does anyone know why the Print function works in DEBUG mode, but not in RELEASE mode (it is blank)? (Visiual C++ 6.0).
Thanks.
mnnca
|
|
|
|
|
what is the difference between debug mode and release mode?
|
|
|
|
|
When I compile it (single document MFC app) in debug mode, the document has the right data (on the view and printer).
When I compile it in release mode, the document is always blank.
mnnca
|
|
|
|
|
What Print function? What "is blank"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I use standard code from MFC examples:
void CDISKVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CDISKVERDoc* pDoc = GetDocument();
CScrollView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_ANISOTROPIC);
CSize sizeDoc = pDoc->GetDocSize();
sizeDoc.cy = -sizeDoc.cy;
pDC->SetWindowExt(sizeDoc);
CSize sizeNum, sizeDenom;
sizeNum.cx=1;
sizeNum.cy=1;
sizeDenom.cx=1;
sizeDenom.cy=1;
//debug mode works ok
//release mode doesnt work !!dont know why
// GetZoomFactor(&sizeNum, &sizeDenom); this is not a valid function, why?
int xLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSX);
int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
long xExt = (long)sizeDoc.cx * xLogPixPerInch * sizeNum.cx;
xExt /= 100 * (long)sizeDenom.cx;
long yExt = (long)sizeDoc.cy * yLogPixPerInch * sizeNum.cy;
yExt /= 100 * (long)sizeDenom.cy;
pDC->SetViewportExt((int)xExt, (int)-yExt);
}
The Print function:
pDC->TextOut(x,y, String1);
When I compile it in debug mode, the output/document is ok.
when I compile it in release mode, the output is a blank page.
Thanks.
Mandy
mnnca
|
|
|
|
|
Hmm...besides rendering to coordinates that don't map to a visible
area of the page, I can't see what would cause the page to be blank.
You could try adding debug info to your release build project
C++ and linker settings and step throu in the debugger and see if
maybe there's an improperly used ASSERT() macro somewhere or
check values in your printing code to see if you're getting what you
expect.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi:
Thanks for the tips.
I inserted lots of debug statements (in release mode) to display the cordinates (x,y), they look ok (within page boundary).
There are differences between the debug and release libraries (MSVCRTD.dll, MFC42D.dll, MFCO42D.dll).
One difference I found is the height of the TEXTMETRIC. I even tried to set it to a fixed value (17, as seen in debug mode), it still doesnt work.
mnnca
mnnca
|
|
|
|
|
That's a tough one.
It looks like all your y coordinates (when drawing) should be negative
to be visible. Is that the case?
You can try using a window DC instead of a printer DC (like print-preview).
Saves time debugging and maybe you'll see something that you're not seeing
on the printed pages.
You may want to go through the project settings and compare ALL
settings between the release and debug. Make sure there's not a
release setting that would obviously change behavior.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|