|
Rane wrote: I'm trying to register a DLL created by Visual Studio 2005 in Debug Mode.It fails with the return code as 0xc0000005.
Are you using regsvr32.exe ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well I am working on VC++ and I wish to develop an application that creates an xml file. Can anybody guide ??
-- modified at 2:38 Wednesday 23rd May, 2007
|
|
|
|
|
kunal.tawde wrote: Well I am working on VC++ and I wish to develop an application taht creates an xml file. Can anybody guide ??
MSXML[^
Look up this[^] too.
|
|
|
|
|
|
Well thanks for tyour precious guidance..
|
|
|
|
|
|
Thanks a lot for your priceless guidance. I will check out the link you sent and I feel that it will work for me.
Once again thanks a lot.
|
|
|
|
|
|
I am trying to create a function that takes a pointer as a parameter that will end up being an array. The function returns the number of elements that will be in the array. I'm having a problem with the allocating part in the function. Here is what I have:
<br />
struct FooStruct<br />
{<br />
int aFoo, bFoo;<br />
}<br />
<br />
int GetFooList(FooStruct *pFoos)<br />
{<br />
<br />
pFoos = new FooStruct[MaxFoos];<br />
<br />
return MaxFoos;<br />
}<br />
My function works, but the problem comes from the calling function. If I create a pointer to a FooStruct and pass that, it does not get updated with the address that the new comes back with. I still don't fully grasp pointers (just the basics) so I may be going about this the wrong way.
I would imagine that this would be a standard situation with programming (calling a function to get an unknown number of items returned), but I don't know what this would be called so my searches have not come up with anything useful. Is this a good way to achieve what I am looking for, or am I wandering down the wrong path?
Any suggestions or pointers (sorry for the pun) on ways to accomplish this would be greatly appreciated!!
|
|
|
|
|
hpjchobbes wrote: My function works, but the problem comes from the calling function. If I create a pointer to a FooStruct and pass that, it does not get updated with the address that the new comes back with. I still don't fully grasp pointers (just the basics) so I may be going about this the wrong way.
That is the standard behavior. To make things easier, see pointers as being a value (the value is the address of a certain memory area). Thus you are in fact passing a value to a function, and the function will make a copy of this value for itself. You create a new array and you store this new value in the copy. Thus, your calling function will never be updated.
To solve this 'problem', pass the pointer by reference. This instruct your function that it must work on the variable and not make a copy of it:
int GetFooList(FooStruct* &pFoos)
|
|
|
|
|
In short:
int GetFooList( FooStruct **ppFoos ) {
...
*ppFoos = new FooStruct[MaxFoos];
return(MaxFoos);
}
FooStruct *pFoos = NULL;
int nFoos = GetFooList(&pFoos);
In long:
A pointer is just another data type like an integer (char, short, int, long, long long) or real (float, double).
So, turn the function around, what if you wanted to return the pointer and update the size as a parameter:
FooStruct* GetFooList( int *nFoos ) {
...
FooStruct *pfs = new FooStruct[MaxFoos];
*nFoos = MaxFoos;
return(pfs);
}
int nFoos = 0;
FoosStuct *pFoos = GetFooList(&nFoos);
Don't get wrapped up by the fact that a pointer data type is defined with a *.
[EDIT]
Or, as Cedric pointed out, use references.
I was trying to stay with a pointer based explaination.
[/EDIT]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Well, the reason of failure is; "I still don't fully grasp pointers (just the basics)"
The problem is that you pass the pointer by value; IOW the actual pointer gets copied and the very copy is passed to the function. Inside of the function, you assign the address [returned by new] to the copy of the original pointer and thus the original pointer will not be affected.
To make it work as you expect, make the following changes in the function prototype;
int GetFooList(FooStruct *& pFoos) {
...
}
Noticed? Now you pass the pointer by its reference.
--
=====
Arman
|
|
|
|
|
struct FooStruct
{
int aFoo, bFoo;
};
int GetFooList(FooStruct * & pFoos)
{
// Find out the max foos we're going to have
pFoos = new FooStruct[MaxFoos];
return MaxFoos;
}
|
|
|
|
|
See this thread.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I see where my mistake was. I was not thinking of the pointer being passed as a value. Thanks everyone for the replies. I'm going to need to play around with this a lot more so I get a full understanding of it! I also like the idea of swapping the parameter and the return value. This is a lot easier to understand. I should have thought of that myself. I'll read up on the link that was provided. I did some searches on 'array pointer', but everything I found was about having a known array size at compile time. Thanks for the link, it looks like it has a lot of good information!
|
|
|
|
|
Hello,
I don't have vc++ documentation with me on my PC.From where can I download it .Is there any link
Prithaa
|
|
|
|
|
Try and use MSDN Library. I didn't find anything better than this.
Anurag Gandhi.
|
|
|
|
|
Thanks Anurag
I will do that
Prithaa
|
|
|
|
|
hye,
I m new to VC++
i wrote a simple program in VC++
following is the code :
#include<afxwin.h>
class CMainWin :public CFrameWnd
{
public:
CMainWin();
Declare_Message_Map()
};
CMainWin ::CMainWin()
{
Create(NULL,"Hello");
}
class CApp:public CWinApp
{
bool InitInstace();
};
Bool CApp :: InitInstance()
{
m_pMainWnd=new MainWin;
m_pMainWnd ->ShowWindow(m_nCmdShow);
m_pMainWnd ->UpdateWindow();
return true;
}
Begin_Message_Map(CMainWin,CFrameWnd)
End_Message_Map()
CApp App;
but i m gtng two errors
1) syntax error : missing ';' before type 'long'
2)fatal error C1004: unexpected end of file found
Neha
|
|
|
|
|
Use:
#include "stdafx.h"
and then try.
for all string, write: _T("") instead of "".
For example, write _T("Hello") instead of "Hello".
I think this will help.
Anurag Gandhi.
|
|
|
|
|
what u suggested is not working (stdafx.h)
also,i m using create function then how to use :
_T("Hello") instead of "Hello".
neha
|
|
|
|
|
Whats header file of your program ?
|
|
|
|
|
Dear Neha,
One thing is that, your project might have enabled precompiled header. So that you have to include stdafx.h in your project or remove the pre-compiled header setting for the file from project properties.
Declare_Message_Map() is actually DECLARE_MESSAGE_MAP() hope you are aware about this. Please put the right source code and complete error message to get your problem solved.
I think you can approach Visual C++ Create Simple SDI for you.
I doubt your "Create" function will succeed because you have to give a valid class name for the window.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Still not working
any other clue???????
pls help me out
neha
|
|
|
|
|
Please post the correct code and error messages.
Are you dealing everything in a single CPP file?
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|