Click here to Skip to main content
15,905,427 members

Comments by sanathbt (Top 5 by date)

sanathbt 3-Oct-11 7:18am View    
Now I am reading the system time by using time.h . I want to subtract 5 minutes from that time...
sanathbt 30-Sep-11 7:42am View    
I am not getting the remaining logic only... I tried my logic its giving -ve values for some input.
If you know the logic, give me suggestion.... That logic to work for everything like leap year etc....
sanathbt 30-Sep-11 7:27am View    
is this for c++? If yes tell me which header i have to use...
sanathbt 26-Sep-11 8:35am View    
the create thread will execute the function in different thread in the same process. How i want is that the function has to be execute in the background in different process. Me attaching the code below.

In this program, the add() function will run in background process, after the completion of the whole function, the background process will be closed but the original process remains as it is... How to delete that process...


#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <windows.h>
#include <stdlib.h>
using namespace std;


DWORD WINAPI add( LPVOID lpParameter)
{
int a,b,c;
cout<<"a:";
cin>>a;
cout<<endl;
cout<<"b:"<<endl;
cin>>b;
c=a+b;
cout<<"sum(c)="<<c<<endl;
return 0;
}

void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait){}
}

int main ()
{
DWORD dwThreadID;
int n,frequency;
HANDLE hProcess;
PROCESS_INFORMATION processInformation;
STARTUPINFO startupInfo;
cout<<"enter the frequency:";
cin>>frequency;
CreateProcess(TEXT("sameprocess.exe"), NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &processInformation);
for(int i=0;i<2;i++)
{

HANDLE hThread = CreateThread(0,0,add,0,0,&dwThreadID);
cout<<"hi hello";
wait (frequency);
}
printf ("FIRE!!!\n");
//WaitForSingleObject( processInformation.hProcess, INFINITE );
CloseHandle( processInformation.hProcess );
CloseHandle( processInformation.hThread );
return 0;
}


And my program is not waiting for the user input , give me a solution for this..
sanathbt 19-Sep-11 8:59am View    
Ya exactly..