Creating a 2h timer in C [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Improve this question
I'm doing this project at work, and in my entire(short) career as a developer, I have never had to use anything related to time measurements in coding. However, I am now programming an electronic door that will lock in certain conditions. And I can't for the life of me figure out how to do it. Am I just supposed to use the time functions available? Because I'm pretty sure I can't use it considering it isn't present anywhere else in any project under my Team Leader.
Details:
there is an alarm system that has different states
when the alarm system IS NOT "LOCKED" (AlarmStatus != LOCKED) -> a timer starts that will count until 2 hours (I'm guessing I'll have to go for a WHILE LOOP here)
if AlarmStatus changes to LOCKED during these 2 hours, the timer will immediately reset
if the timer reaches 2 hours, the AlarmStatus will forcefully be transitioned to LOCKED and the timer will once again immediately reset
This is basically the gist of it, and I know it's not anything difficult, but I am unsure how to create that timer and reset it, and most importantly, how to measure the passage of time. Is there a way to do it without using functions from "time.h"?
Thanks all in advance for your time and responses!

Related

Apertura de form en C# [closed]

Closed. This question is not written in English. It is not currently accepting answers.
Stack Overflow is an English-only site. The author must be able to communicate in English to understand and engage with any comments and/or answers their question receives. Don't translate this post for the author; machine translations can be inaccurate, and even human translations can alter the intended meaning of the post.
Closed 9 days ago.
This post was edited and submitted for review 9 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Good day people, sorry to bother with a consultation that is sure is very easy but I am very new to the subject and there are simple things that complicate me. The issue is that I have a Form which is the main screen and from the menu I call another Form (Customers) and without closing this second I want to open a third (Articles) but it does not let me open it until the first child closes. This is all in C#. I would appreciate it if someone could explain to me how I should do it. Thank you
I've always called with .Show() but in this case I do not know how to do it

Using AI generators to ask questions to provoke thinking instead of giving answers? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a use case that I want to use to help independent creators talk about their interests on Twitter using their experiences.
It goes like this:
You have an interest you want to talk about Entrepreneurship
You have an experience like Pain
Is there a way for an AI (like GPT) to generate prompts that uses these two words to create a list of open-ended questions that provoke thoughts such as these:
If entrepreneurship wasn't painful, what would it look like?
What do you know about entrepreneurship that is painful that starters should know?
How can you lower the barrier to entrepreneurship so that it's a less painful opportunity for a person to take?
If so, how will it work, and what do I need to do?
I've explored Open AI's documentation on GPT-3, I'm unclear if it solves this problem of generating prompts.
Thanks!
You should provide some samples so that the GPT-3 can see the pattern and produce a sensible response from your prompt.
For example, see the following screenshot from your case. Note that the bold text is my prompt. The regular text is the response from GPT-3. In that example, I was "priming" the GPT-3 with relevant pattern: First line, the general description, then the Topics, followed by Questions. This should be enough for booting up your ideas and customizations.

Detect Key Press on Windows Without Window Focus [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've been searching online but all the top results on Google only lead me to Java. This is frustrating.
What I want to do is: make a program that listens to keyboard events, without being the active program. It has to work on at least windows 7, using C.
For example lets say I have myprogram.exe and other.exe. I want to be able to run both of them simultaneously, and have focus on other.exe, then press keys, and have myprogram.exe which runs on the side display which keys I pressed and log them.
If somebody has a link to a guide or information that explains what I should use to make this, that would be grand. If you can write up an explanation yourself that would be even better, but I don't mind going through documentations as long as they're relevant.
I've written games in C that listen to input from the active window, but I'm not sure how to poll events when the window isn't focused.
If you want to detect 'key press' events occurred in other processes, you should implement Global Hook. You can define a callback function for keyboard input events using SetWindowsHookEx().
Note that the callback function must be in a DLL in order to make it Global Hook.
So your myprogram.exe should link a dll implementing the hook. Then myprogram.exe would be able to detect any keyboard events on Windows.
Following is a good example with an explanation.
http://www.codeproject.com/Articles/1264/KeyBoard-Hooks

Putting a time restraint on the users input [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am trying to create a C program which will create a wordsearch and then give the user a time to complete it in and then the program will output a message accordingly. My problem is that I cannot figure out how to ask the user for input while counting down. Any help is appreciated.
Make the user input method it's own thread, a child of the main thread. Use wait in the main thread and then end the child thread when the wait is over. Let us know if you have questions on how to create threads or how to use mutex to keep data secure.

What is the point of encapsulation? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I just don't see the point of encapsulation, I see that in some cases you can modify a getter/setter to modify the behavior of something or keep track of state, but whenever I am creating a non-conventional getter/setter, I use a word like "modify," or "obtain," so what is the point of wasting hours writing repetitive methods that are practically pointless and inefficient?
I just don't get it, when I was a wee young programmer, I was told by some guy in an IRC, that not having it was the cause for a bug in my program, but I have known for years now that is not the case, I've just been doing it anyway, so what is then point?
If I need to refactor later there are ways around it weird ones but they are ways at least in languages with overloaded operators, and API's don't always have to be backwards compatible so I don't see the point.
Can anyone enlighten me to the necessity of encapsulation?
In many cases you are right - small programs doesn't need encapsulation probably.
Some MS infrastructures (C#/WPF I think in several binding scenarios) requires encapsulation (using properties) and will not work without it.
If you do more in get / set than changing the value or returning it - it will make your code nicer and more robust (do checks, or other staff in the setter for example).
No one forces you to use it anyway...

Resources