I have a weird requirement and have no clue. I have a variable in C which I want to get it using scanf or something similar but say in pace of integer if one enters non-integer then program should restart.
Any suggestions??
If the code is in embedded, some hardware changes may also be required whereby, you pull ON/OFF of an IO pin, which in turn tied to the reset pin of the controller/processor, with additional circuit to pull OFF/ON of the reset pin automatically (once reset done, MCU/MPU goes OFF, which need to be started).
If the code is in non-embedded (say PC), you need to structure the code such that an infinite loop continuously runs inside main with multiple conditions (one of the condition to check user input) and you can re-initialize all the variables, and continue executing rest of the code.
Use your imagination and try to draw on paper (flow chart) of what happens in the code, and try to introduce your condition in the flow chart. You will arrive at the answer for your question.
Given input as a string, return an integer as the sum of all numbers found in the string
Input: xyzonexyztwothreeeabrminusseven Output : 1 + 23 + (-7) = 17
Input: My SpAce Output: mY sPaCE