|
Hi all!
I want to build a program to manage other processes. The program is responsible for any process that suddenly stops and the program will call back that process. I am wondering how to use CreateEvent() to create a global event variable to manage it. I hope you give me advice and methods to solve that problem.
Thank you!
|
|
|
|
|
|
It is true that the program I will develop should be a service. Do you have experience with this issue please share with me. thank you very much!
|
|
|
|
|
Here is but one of many examples.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Well, it was more than six years back... I used the NSSM - the Non-Sucking Service Manager
The most important thing is you could used the original UI application to use with..., however, in "service" mode you must forbid all UI features.
|
|
|
|
|
I'm trying to change a given string in a function, but I send a string, try to change it directly and get a core dump, so I tried to create a string in the function, but it doesn't send the correct string.
This function must eliminate all Capital letter's it's a simple one, but I am making a mistake and don't see where.
Can any one help me please.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define false 1
#define true 0
char* my_strdelupper(char* s){
int i,j, len;
char aux[100];
char debuging;
len = strlen(s);
j = 0;
for (i = 0; *(s + i) != '\0' < len; i++){
if (!isupper(*(s+i))){
printf("%c",*(s+i));
debuging = *(s + i);
*(aux + j) = debuging;
j++;
}
}
*(aux + j) = '\0';
printf("\n");
puts(aux);
return strcpy(aux, aux);
}
int main()
{
char *s3="Quem quer casar com um programador?";
printf("%s\n",my_strdelupper(s3));
return 0;
}
|
|
|
|
|
Why not using the std::string with all its and other std methods?
|
|
|
|
|
|
You have: char *s3 = "..." . Although s3 is declared as char * the type of the string is const char * . Use char s3[] = "..." instead.
|
|
|
|
|
|
If I were to hazard a guess, I'd say it has to do with aux being destroyed (i.e., going out of scope) once my_strdelupper() returns.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I think you are correct, but I tried to copy aux to s and didn't work, now I changed the code to send an array, them befour I leave I copy using srtcpy aux to s, and it's working.
|
|
|
|
|
This line of code puzzles me:
*(s + i) != '\0' < len It probably should be:
i < len
A second problem is that you are doing the copy only on !isupper, when you should be doing it always as soon as an uppercase character is detected.
A third problem is the strcpy() at the end. It's pointless.
A fourth problem is that you are returning a pointer to the a stack value which becomes invalid because the call to printf is likely overwriting it and is likely causing a fault.
modified 8-Jun-19 1:10am.
|
|
|
|
|
You are correct, that was one mistake, but it should be *(s + i) != '\0' because I am searching for the end of line.
|
|
|
|
|
Try this:
char* my_strdelupper(char* s){
int i, len;
char* sl;
len = strlen(s);
sl = (char*)malloc(len+1); i = 0; while (*s != '\0'){
if (!isupper(*s)){
sl[i++] = *s; }
s++;
}
sl[i] = '\0';
printf("%s\n", sl);
return sl;
}
|
|
|
|
|
The stupid thing is that I can't use malloc, so I made a char array with fixed size to overcame that problem.
|
|
|
|
|
Thank you, for all, it was a great help.
The problem was solved by:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define false 1
#define true 0
char* my_strdelupper(char* s){
int i,j, len;
char aux[100];
char debuging;
len = strlen(s);
j = 0;
for (i = 0; *(s + i) != '\0'; i++){
if (!isupper(*(s+i))){
debuging = *(s + i);
*(aux + j) = debuging;
j++;
}
}
*(aux + j) = '\0';
strcpy(s, aux);
return s;
}
int main()
{
char s3[]="Maria, TU sabes que TU éS o meu \"Grande Amor\"";
printf("%s\n",my_strdelupper(&s3[0]));
return 0;
}
|
|
|
|
|
As a note - you define 'len' but you don't use it.
Presumably the assignment does not say otherwise, using that would make your code simpler.
|
|
|
|
|
Note you don't need extra storage, the function may change the string in place:
char * remove_upper( char * s)
{
char * p, *q;
for (p = q = s; *p != '\0'; ++p)
if ( ! isupper(*p) )
*q++ = *p;
*q = '\0';
return s;
}
|
|
|
|
|
Taken from K&R 1st ed? Certainly has that feel>
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
It is the Wonderful C programming language, of course has such a feel.
In any case, were Dennis and Brian the ones who plagiarized my programs. 
|
|
|
|
|
I was begging to think no one here was thinking.
Thanks
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
I have copied a program from CrazyGeeks website and modified some of its statements. Anyone please tell me whats wrong in below code:
#include <iostream>
using namespace std;
int main()
{
int count, j, elements[50], search_num, first, last, mid;
cout<<"Enter the total number of elements :";
cin>>count;
cout<<"\nEnter ">>count>>" numbers:\n";
for (j=0; j<count; j++)
{
cin>>elements[j];
}
cout<<"\nWhich number that you want to search: ";
cin>>search_num;
first = 0;
last = count-1;
mid = (first+last)/2;
while (first <= last)
{
if(elements[mid] > search_num){
first = mid + 1;
}
else if(elements[mid] == search_num){
cout<<search_num<<" found in array at "<<mid+1<<"\n";
break;
}
else {
last = mid - 1;
}
mid = (first + last)/2;
}
if(first > last){
cout<<search_num<<" Not found in an array";
}
return 0;
}
Code link
|
|
|
|
|
Quote: cout<<"\nEnter ">>count>>" numbers:\n";
Should be
out << "\nEnter " << count << " numbers:\n";
You should ask the user for an ordered sequence, in order to make the binary search work.
Your code is very C -like, you didn't take advantange of the wonderful features of modern C++ . 
|
|
|
|
|