|
Exactly the same as if it was a variable: pass it by reference.
|
|
|
|
|
Like this???
void fun(int* ptr){
ptr = (int*)malloc(sizeof(int));
}
int main(){
int ptr;
fun(&ptr);
ptr = 5;
cout<<ptr;
}
I dont think so..
probably you mean something else.. that i am not getting.
modified on Monday, September 29, 2008 8:40 AM
|
|
|
|
|
Use &.
void fun(int*&ptr)
{
}
then in the main function
fun(ptr)
Is it working now?
modified 7-Mar-17 16:31pm.
|
|
|
|
|
Well, you need something a bit more elaborated (plain C ):
void myAlloc(int ** ptr)
{
*ptr = (int *) malloc(sizeof(int));
}
int main()
{
int * pMyInt;
myAlloc( &pMyInt);
*pMyInt = 5;
printf("%d\n", *pMyInt);
free( pMyInt)
}
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]
|
|
|
|
|
Yes, this is exactly what I was trying to do..
Thanks a lot, all of you
|
|
|
|
|
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]
|
|
|
|
|
|
when i initialize a list iterator with an integer, it gives compile error as follows:
list <int >::iterator iter;
iter = 0; //this gives an error c2679 when build in release mode
but the same code works fine when i build in debug mode.
why? can any body put some light on this?
(am using visual studio 2005)
thank u
|
|
|
|
|
what if you initialize the iterator correctly ?
list <int>::iterator iter;
iter = mylist.begin();
where mylist is an instance of the class list<int>
|
|
|
|
|
This[^] explains why (debug mode has the _HAS_ITERATOR_DEBUGGING macro set)
In general you shouldn't create iterators from pointers (0 is being treated as the NULL pointer). If you want to ensure that the iterator references nothing then set it via mylist.end().
Graham
Librarians rule, Ook!
modified on Monday, September 29, 2008 9:08 AM
|
|
|
|
|
in my dll I am exporting a function
extern "C" __declspec(dllexport) void __cdecl setdata(int num);
in my application I defined the function
typedef void (__cdecl *SETDATA)(int num);
SETDATA setdata;
now I write the code
HINSTANCE hDll = LoadLibrary("mydll.dll");
if(!hDll)
{
return;
}
//ok fine library load
setdata=(SETDATA)GetProcAddress(hDll,"setdata");
//here it setdata not receiving and show NULL address of setdata function why?
but same working fine when I statically link?
Trioum
|
|
|
|
|
From GetProcAddress documentation [^]:
Return Value
If the function succeeds, the return value is the address of the exported function or variable.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
BTW Have a look at the actual exported function name (you may use depends.exe for the purpose).
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]
|
|
|
|
|
i am getting the error code 127
Trioum
|
|
|
|
|
trioum wrote: i am getting the error code 127
That is: "The specified procedure could not be found".
Have you used depends.exe to see the actual exported name of your procedure?
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]
|
|
|
|
|
Hi,
I am using CListView control, there to get the ClistView style i used a message ON_MESSAGE "LVM_GETVIEW", i define a method for this message, but when i complied it throwing error as
error C2065: 'LVM_GETVIEW' : undeclared identifier
please help me.
|
|
|
|
|
Did you include (as required) commctrl.h ?
BTW I think you should use SendMessage with LVM_GETVIEW , see [^].
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]
|
|
|
|
|
Hi,
yes, i include "commctrl.h". i am using in mfc, so it is possible to "SendMessage" ?.
i used as
ON_ Message(LVM_GETVIEW,onGetStyle)
then i implement onGetStyle()method. After that i complie it, an error message was occur "error C2065: 'LVM_GETVIEW' : undeclared identifier" at compile time itself
|
|
|
|
|
Bernaad wrote: i am using in mfc
Ok, from a previous post of yours, I thought the opposite. Anyway, if you are using MFC, why not simply use GetView[^] ?
|
|
|
|
|
Bernaad wrote: yes, i include "commctrl.h". i am using in mfc, so it is possible to "SendMessage" ?.
Yes.
Bernaad wrote: error C2065: 'LVM_GETVIEW' : undeclared identifier"
You have to define _WIN32_WINNT greater or equal to 0x0501 .
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]
|
|
|
|
|
Bernaad wrote: I am using CListView control, there to get the ClistView style i used a message ON_MESSAGE "LVM_GETVIEW"
As far as I remember, you were using the Win32 API and no MFC, right ? ON_MESSAGE is a MFC macro.
|
|
|
|
|
yes i am using ON_MESSAGE macro, there only i am geting error "LVM_GETVIEW" is undeclared identifier. how can i avoid that error. please you have any idea.
|
|
|
|
|
|
Hi all,
I wanted to get logical drives of my particular hard disk(i.e suppose we have two hard disk and one removable media attached to my system than first it should get first hard disk and its logical partition then second and its partition and accordingly..).
How can i do this or which api's to use for it..
Thanks in advance
|
|
|
|
|
|
Hi All
Am new to this group.Kindly help me to ressolve this issue...
I am going to create an application from such that it reads the data from excel sheet and this datas should be transferred to combo box. I feel that reading data from xl sheet is possible .So any one can suggest this to solve this issue..
Thanks in advance
Regards
Ganesh.P
|
|
|
|