|
You should be able to give the new process a different security context by using lpProcessAttributes->lpSecurityDescriptor .
|
|
|
|
|
Consider the following code in C:
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
scanf("%s",n);
printf("%s");
getch();
}
Question: The above program amazingly reads a string and prints it but I don't know how/ Plz help me.
Plz specify the working of scanf and printf in the above program. n is not given as an address to the scanf function and printf contain only format strings.
Awaiting a good reply
|
|
|
|
|
In the scanf call, scanf will take n to be a char* value, so will store the string read in at the address given by n. You're just 'lucky' that n's value is equivalent to a writeable address.
The printf call? Well, as printf is a variadic funtion, it'll look up the stack from the pushed format string, looking for argument values. The next value on the stack above the format string is (you guessed it!) n, so printf will see n, interpret it as a char* value and print the string at that address.
The joys of a type-unsafe system programming language
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am working on MFC Asynchronoussocket program, I could able to successfully send and receive messages between one to one client and server using accept, receive classes. But when i am trying to connect multiple client to server, my application crashes. And I also wonder, if I able to accept multiple client, how would I match the send and receive messages between different clients and server.
Could anyone please help me out!!!
Thanks
Reddy
|
|
|
|
|
reddy07 wrote: And I also wonder, if I able to accept multiple client, how would I match the send and receive messages between different clients and server.
I've only looked at the basics of this quite some time ago, but the structure that accept() populates on the server has a sin_addr member. Can you pass that to inet_ntoa() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks david, I solved it - now I could able to establish mulitple client with single server, but I am facing problem in receving messages from clients. Server couldnt receive the message that client is sending. On client side, client is sucessfully sending the message. Could you please throw some light.
Binding i will look into it later once server start receving messages
|
|
|
|
|
Hi.
I have a program which is creating a huge memory leak. Here is an example of my program. This is not an actual code but an example which references my program.
Class ABC
{
static int *B;
}
Class DEF{
int *MALLOC_C[20];
void Function1(int* ptr);
void Function2( );
}
ABC[10];
DEF[10];
void main()
{
int *sample=new sample();
*sample=1;
ABC* Object1[20];
DEF* Object2[20];
for(int i=0;i<20;i++) //Edited
{
Object1[i]=new ABC();
Object2[i]=new DEF();
}
for(int i=0;i<20;i++)
{
Object[i].Function1(sample);
}
for(int i=0;i<20;i++)
{
delete Object1[i];
delete Object2[i];
}
}
DEF::Function1(int *ptr)
{
ABC::B=ptr;
}
DEF::Function2()
{
for(int i=0;i<20;i++)
{MALLOC_C[i]=(int*) malloc(1000*sizeof(int) ); //Edited,Corrected
}
//DO processing on MALLOC_C
for(int i=0;i<20;i++)
free(MALLOC_c[i]);
}
This is what I am doing. What is wrong? Please help!
modified on Wednesday, June 3, 2009 10:08 PM
|
|
|
|
|
jobin007007 wrote: MALLOC_C=(int*) malloc(1000*sizeof(int) );
why is this line inside a for(i) loop and not using i?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
My mistake. Its been edited.
It should have been-
MALLOC_C[i]=(int*) malloc(1000*sizeof(int) );
Thanks
|
|
|
|
|
Leaks maybe in this
int *sample=new sample();
And below makes infinite loop
for(int i=0;i<20)
{
Object1[i]=new ABC();
Object2[i]=new DEF();
}
If you use VC, microsoft provides some helpfull debug runtime like _CrtCheckMemory.
If you do not, make memory management library or use some like those.
Happy debug!
|
|
|
|
|
It was a stupid variable issue.
I was not going through the whole array
Basically I was doing the below->
for(int i=0;i<20;i++)
{
MALLOC_C[i]=(int*) malloc(1000*sizeof(int) ); //Edited,Corrected
}
for(int i=0;i<10;i++) //Notice the 10. It should have been 20
free(MALLOC_c[i]);
|
|
|
|
|
Hallo in my SDI-Application i have the following problem: when i write something and click close or exit the application
does not ask me if i want to save the document /file or not(the prompt message does not appear???) please help.
|
|
|
|
|
Have you called the document's SetModifiedFlag() method?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i have now the following Code :
When i click on the close or exit button, OnDeleteContents() will be called:
void CTest_Doc::OnDeleteContents()
{
CDocument::DeleteContents ();
CDocument::OnCloseDocument();
CDocument::SetModifiedFlag(1);
}
after that there is a heap problem???
|
|
|
|
|
okay i corrected :
void CTest_Doc::OnDeleteContents()
{
CDocument::SetModifiedFlag(1);
CDocument::DeleteContents ();
CDocument::OnCloseDocument();
}
but the Prompt save message stiil not appear??
|
|
|
|
|
susanne1 wrote:
but the Prompt save message stiil not appear??
Because you are possibly calling SetModifiedFlag() too late. It needs to be called as soon as the document changes.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am facing issue while implementing restart manager in VS 2005 MFC project. it is saying restartmanager.h is not found. I am implementing this for W2k8 and Vista OS. I am not getting information about Which VS support this. I found VS 2005 C# is supporting this.
Would it be possible to implement restart manager in VS 2005 MFC project?
|
|
|
|
|
|
Hi,
I'm facing some problem when trying to build my solution in Release mode(building in debug mode works fine).
My solution contains several project(10 of them are static libraries and one is the executable which uses those libraries).
One of the static libraries is the GUI implementation(MFC).
I've configured the properties of each project in release mode(e.g. use MFC as a shared DLL , use runtime library as Multi-Threaded DLL[\Md] etc.).
I've managed to compile the entire solution,but failed to link the executable.
I'm getting the following error
<br />
Linking...<br />
GsaActLib.lib(g_act_hndlact.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification<br />
mfcs80.lib(nolib.obj) : warning LNK4098: defaultlib 'nafxcw.lib' conflicts with use of other libs; use /NODEFAULTLIB:library<br />
HmiLib.lib(h_windsp_formMng.obj) : error LNK2019: unresolved external symbol __imp___invalid_parameter_noinfo referenced in function "public: bool __thiscall std::_Tree<class std::_Tmap_traits<class IlvGadgetContainer *,int,struct std::less<class IlvGadgetContainer *>,class std::allocator<struct std::pair<class IlvGadgetContainer * const,int> >,0> >::const_iterator::operator==(class std::_Tree<class std::_Tmap_traits<class IlvGadgetContainer *,int,struct std::less<class IlvGadgetContainer *>,class std::allocator<struct std::pair<class IlvGadgetContainer * const,int> >,0> >::const_iterator const &)const " (??8const_iterator@?$_Tree@V?$_Tmap_traits@PAVIlvGadgetContainer@@HU?$less@PAVIlvGadgetContainer@@@std@@V?$allocator@U?$pair@QAVIlvGadgetContainer@@H@std@@@3@$0A@@std@@@std@@QBE_NABV012@@Z)<br />
HmiLib.lib(h_utils_studio_attrGadget.obj) : error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo<br />
HmiLib.lib(h_utils_studio_enumGadget.obj) : error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo<br />
HmiLib.lib(h_utils_studio_egGadget.obj) : error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo<br />
.\Release/link.exe : fatal error LNK1120: 1 unresolved externals<br />
<br />
Error executing link.exe (tool returned code: 1120)<br />
<br />
Newlink - 5 error(s), 68 warning(s)<br />
I've trying to google a little bit but didn't find an explanation for the above error.
Anyone?
With best regards,
Eli
|
|
|
|
|
eli15021979 wrote: GsaActLib.lib(g_act_hndlact.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
...
I've trying to google a little bit but didn't find an explanation for the above error.
Did you look here?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi David.
Thanks for your help,but this warning is not my problem...
I know that my problem is the errors below(LNK2001)...I just can't find the call for invalid_parameter_noinfo.
According to MSDN(relating LNK2001):
When compiling with /MD, a reference to "func" in your source becomes a reference "__imp__func" in the object since all the run-time is now held within a DLL. If you try to link with the static libraries LIBC.lib or LIBCMT.lib, you will get LNK2001 on __imp__func. If you try to link with MSVCxx.lib when compiling without /MD you will not always get LNK2001, but you will likely have other problems.
All the libraries in the solution,as well as the executable, are being compiled with /Md option(i.e runtime library is a multhi-threaded DLL).
In the linker option I specified the linker to ignore LIBC,LIBCMT and MSVCRT default libraries.
But still,I get those error...
Anything?
Thanks again,
Best regards,
Eli
|
|
|
|
|
Hi David,
I removed MSVCRT.lib from default libraries ignore list and it's working just fine.
Thanks again,
Eli
|
|
|
|
|
Your post was helpful for me too!!
Thank you!!!
|
|
|
|
|
|
This explains the fact.
error LNK2019: unresolved external symbol __imp___invalid_parameter_noinfo
This means program calls invalid_parameter_noinfo() but no symbols around libraries.
If you did not call this function directly, some libraries (guess MFC?) call it.
You can try goole with keyword by invalid_parameter_noinfo.
|
|
|
|