|
I will really, really appreciate comments about a discussion in another web site. The reason I am asking here is because I feel unable to get an objective answer in the other site.
See the CodeGuru Forums - struct vs class? thread. I posted a message saying that the question did not ask about C structures. I will appreciate knowing if my comment is valid.
-- modified at 23:48 Saturday 20th May, 2006
|
|
|
|
|
Sam Hobbs wrote: The reason I am asking here is because I feel unable to get an objective answer in the other site.
I read through the posts but I'm not sure what your question was. You stated a "matter of factly" thing. Case closed.
The other participants seem preoccupied with quoting their textbooks. The question was too vague to begin with and warrants the issuer open a few books him/her self.
|
|
|
|
|
Thank you. Yes, I was vague intentionally. I wanted to be fair and not influence people's reaction.
|
|
|
|
|
I meant the original question that was posted by the thread initiator was vague (Sorry about any confusion). Your comment seemed appropriate based on where the thread was heading vs. what was asked.
Concerning your thread here, I wasn't sure what "objective answer" you were searching for but for what it was worth, you seemed to be stating facts and staying well within the boundaries of correctness.
|
|
|
|
|
Thank you. I sure feel good about getting support and such. I certainly felt that I was being reasonable.
I must insist however that my original question here is vague and I intended it to be.
So what I can do is if I were try to explain to anyone that there is a problem with the attitude of people in the CodeGuru forums and if someone were to try to defend the moderator person there then I can say that people in a more independent forum have expressed a different opinion. I hope it is reasonable for me to do that. It is my intent to do that in a mature, reasonable and productive manner.
-- modified at 23:06 Sunday 21st May, 2006
|
|
|
|
|
because the original-poster asked a question comparing struct+class, I would also limit my response to issues regarding C++ only - so you were right to state this.
The other posters were just trying to be helpful I think, unfortunately they were fairly inaccurate in their description of the C vs C++ issues regarding structs, especially 'andreas' who stated:
"As you can see they are different. That's because in C you are NOT defining a new data type with the definition of a structure. Therefore you need to add the keyword 'struct' in front of the name of the structure when you declare variables of it....In C++, however, a new type is defined when a structure is defined, and you can use this new type to declare variables, and the struct keyword is NOT needed."
this is incorrect, in both C and C++ you are defining a new type "struct name", and it must always be referred to as this. However C++ contains a bodge, and whenever you define a struct in this language it also installs an alias to that struct-type sharing the same name:
In C++ when you do this:
struct mystruct
{
};
It is really doing this (from a C point of view)
struct mystruct
{
};
typedef struct mystruct mystruct;
http://www.catch22.net
|
|
|
|
|
Thank you very much. This really helps.
Note that Andreas is a moderator but I have had problems with him. He really lacks social skills. It seems (to me) that anything he says will be defended (in that forum) and anything I say that conflicts with him will be criticized. Behavior such as that is unproductive. So to the extent that that thread is innacurate, it is important that people say so. I don't want to make it any more personal than what I have said here.
|
|
|
|
|
I am interested in writing a program to video record all screen activity. Similar to screen capture programs (just with video). I posted here to hopefully get some ideas from my fellow coders on how one might go about getting this accomplished. Maybe a video hook similar to remote desktop or VNC. My hope is to record it to an AVi using some compression like Divx or Xvid.
Anyone have any ideas?
Thanks
|
|
|
|
|
|
Thank you for the link. While the documentation helps the library is in .NET (C#) and helps me none for c++. I will read the docs for directShow. If I remember correctly I believe Xvid has there own library in c++ which includes the Directshow filter. I may end up using that if I do not find anything better.
|
|
|
|
|
When the MDI Doc View application starts for the first time, the architecture create the First Document-view without the user intention. How can i avoid this
|
|
|
|
|
In your CMyApp::InitInstance() function add:
if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew )
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
There is an MFC FAQ here on CP which should cover this.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
Ok thanks a lot, i will try this
|
|
|
|
|
i want to check md5
but i don't know how to do
who can tell me?
for example:
md5md5("file path/file name") //return md5 data
very very... thanks
|
|
|
|
|
|
thank you very much
|
|
|
|
|
Hi ,
I have made a dll and exported one int variable, one "struct info Dxinfo", and a function ShowVal().
When in another application I access these variable then all is ok except that I m not able to modify struct Dxinfo, while i m modifying the int varaible (gvar) succesfully in the application. I can read the struct in the application but cant modify.
Code modifying the struct variable Dxinfo is compiled succesfully but produces a runtime "debug assertion failed" message n then application fails to run.
Plz see the code below
This is the cpp file of DLL
//////////// globaldll.cpp ////////////////
#include "afxwin.h"
struct info {int id;CString name;
}
#define DLLEXPORT __declspec(dllexport)
DLLEXPORT int gvar=10;
DLLEXPORT void ShowVar();
DLLEXPORT info Dxinfo;
void ShowVar()
{
Dxinfo.name.Format("LAeeq");
CString s="";
s.Format(" gvar in dll is %d",gvar);
MessageBox(NULL,s,"Info",MB_OK);
s.Format(" name in dll is %s",Dxinfo.name );
MessageBox(NULL,s,"Info",MB_OK);
}
//////////// globaldll.cpp ////////////////
This is code snippet which is accessing the DLL variable n sturct
//////////// globaldll.cpp ////////////////
Dxinfo.name.Format("LAeeq"); // this line produces Debug assertion failed
ShowVar();
gvar+=10;
CString s="";
s.Format("dxinfo.name in testing application is %s",Dxinfo.name);
ShowVar();
AfxMessageBox(s,MB_OK);
///////////////////////////////////////////////////////////
This is the header file in which imports to the application are mentioned in the application testing the DLL
///////////////////////// /////////////GlobalVarDll.h////////////////////////
struct info {int id;CString name;
};
#define DLLIMPORT __declspec(dllimport)
DLLIMPORT int gvar;
DLLIMPORT void ShowVar();
DLLIMPORT info Dxinfo;
////////////////////////////////////////////////////////
Thanx in anticipation
Cyber Friend
|
|
|
|
|
Hi all,
I have solved the issue and posting here for benefit of other persons. The problem was in the CString name member of struct info. I simply changed it with a char array n it worked correctly.
Regards
Cyber Friend
|
|
|
|
|
Hi.
I'm writing a server and client application using sockets. And I have a bug that I can't fix.
The server side software, start a thread that create a socket and when a client connect it calls a function to enumerate the folders and files of the PC where the server runs and it sends the names of files and folders to the client:
BOOL EnumerateFolders ()<br />
{<br />
WIN32_FIND_DATA fd;<br />
<br />
HANDLE hFind = ::FindFirstFile (_T ("*.*"), &fd);<br />
<br />
<br />
<br />
if (hFind != INVALID_HANDLE_VALUE) <br />
{<br />
do <br />
{<br />
CString data = fd.cFileName;<br />
<br />
<br />
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) <br />
{<br />
<br />
if (data != _T (".") && data != _T ("..")) <br />
{<br />
TRACE (_T ("%s\n"), fd.cFileName);<br />
<br />
::SetCurrentDirectory (fd.cFileName);<br />
<br />
if(send(client, data, data.GetLength() , 0) == SOCKET_ERROR)<br />
{<br />
return FALSE;<br />
}<br />
<br />
EnumerateFolders ();<br />
<br />
::SetCurrentDirectory (_T (".."));<br />
}<br />
<br />
}<br />
else<br />
{<br />
TRACE (_T ("%s\n"), fd.cFileName);<br />
<br />
if(send(client, data, data.GetLength() , 0) == SOCKET_ERROR)<br />
{<br />
return FALSE;<br />
}<br />
}<br />
<br />
} while (::FindNextFile (hFind, &fd));<br />
<br />
::FindClose (hFind);<br />
}<br />
<br />
return TRUE;<br />
}
At the client side, after the connection, it starts to receive the strings from server, inside a loop that it ends with a particular string.
Inside the loop, (a do-while), I wrote:
if ((numbytes = recv(client, buf, MAXDATASIZE-1, 0)) == -1) <br />
{<br />
TRACE("recv: %i bytes", numbytes);<br />
<br />
return 1;<br />
}<br />
<br />
temp.Format("%s", buf);<br />
temp.TrimRight ();<br />
So, the CString object "temp", holds the string sent by the server, it works, I can see the data, but instead of see the name of a single folder or file, I see a very long string with a lot of name of folders and files. It looks like the server send faster than client can receive the items, so the data is being concatenate.
Beside this, I'm trying to write the temp object into a text file using a CStdioFile object, but it assert, maybe because of the large of the string.
Where is the problem here?
How could I perform a receive routine at client side to get the strings for every folder and file sent by server?
Or the problem is in the server routine post above??
I will really appreciate any advice.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Before sending the data use the delimiters for each file/folder
for e.g.
CString data = fd.cFileName + "|";
and Tokenize the data on client side with "|"
Hope this helps you.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thankx LAX.
I will do that.
Anyway, I don't know if my routines are "well thinking", because, as I said, the server sends faster than the client can receive, and I could lost data in the process, or not?
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Demian wrote: Anyway, I don't know if my routines are "well thinking", because, as I said, the server sends faster than the client can receive, and I could lost data in the process, or not?
I think you are not loosing any data but you are loosing organisation of data.
So,As it is server it sends data fast due to that before sending organise data and then send so that client can understand it.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi,
i have three views in my application .The first view Name is GroupView..and the remaining to 2 views names are SplitViewOne and SplitViewTwo.i have tree contol in the GroupView.Intially application is loaded with Groupview in one pane and SplitViewOne in other pane .I have toe items in the treecontol one is "SplitViewOne" and "SplitViewTwo" when i click the TreeItem`s in GroupView..the view in the pane will be delted and respective is replaced up to here its fine.I want to hadle same under the button click of toolbar item...have should i handle the toolbar item OnCommand...i have handled it ChildFrame..but the application is crahsing .any idea pls ?
Thank`s in before
James
-- modified at 9:02 Saturday 20th May, 2006
|
|
|
|
|
When you want help with a crash there is a bare minimum of information most people will need:
1. The type of exception.
2. The source code where the crash occured.
3. A stack trace.
Steve
|
|
|
|
|
Hi all.
Is there a way to discover the containing object or class of a MethodInfo?
(i mean the object which the method is its member...)
-- modified at 8:55 Saturday 20th May, 2006
|
|
|
|