Every time a character is input, a lower case standard character, the variable stops incrementing
The value of the variable and of the character are recorded.
The value of the character and of the variable multiply eachother, and each digit is recorded separately as an element in a 100 variable array
The count resets and a variable begins incrementing, repeating the process, until the array has been filled.
As soon as the array is filled, a new array begins.
When three arrays are had, the counting stops.
We now have arrays a, b, and c.
Each element of array c is added to the first element of array b and the first element of array a. The total is whittled down by subtration to a 1 or a 0, 1 incrementing heads and 0 incrementing tails. Then the same is done with the next element of array b. When array b is completed, the process repeats with the second element of array a, and so forth.
I guess array elements could rather multiply eachother, rather than adding, the digits separated and whittled individuallly, and maybe the steps reduced so that dictated patterns are also reduced.
I guess the problem is that the element will already be single digit for all three, so you can’t count on a certain number of digits.
Though I guess if you dictate one, say 3 digits, you could just fill the empty with 0. Maybe 2 digits would be more honest.
If two digits, then you would only need 50 element arrays, and then also only need 10 character inputs per array, 30 total, if you force 5 digits per character variable multiplication.
Now I just need to find a way to make a character input stop a variable increase.
I tried with “while getchar equals 0” or “doesn’t equal X,” but then the program only increments the loop when it sees a getchar.
Variations where the getchar isn’t a condition in the loop but included in the body of the loop results in the same. The loop doesn’t continue if it doesn’t see a getchar if getchar is anywhere in the loop.
The nice thing is that each flip will also be nicely separated, so you can insert whatever kind of count you want really into the code. Heads and tails, but also whatever else.
There is an emergency exit to a loop, which is Ctr C or Z. You can make it print each value until that happens.
So. What about a program that makes that process happen by a getchar.
You press a char, it launches the program. Press another, it emergency exits it, giving you the last printed value.
I mean the annoying thing is that there should be a way to do this with separate functions rather than taking recourse to a whole new program. But I can’t figures it out.
I guess one cannot escape the fact that, in order to capture a character input, the program has to be listening out for it and, to be listening out for it, it has to stop whatever it’s doing.
I have been going over and over it, and I did find something called a time.h library which I might be able to use to make something sort of what I pseudo coded.
But part of me feels like, if I can’t do it with what’s in chapter 1 of the C bible, I don’t fucking feel like doing it at all.
We know you can set off an increment. We know you can manually end it with Ctr C. We know that, otherwise, it will be very hard to end it with anything that isn’t written inside the loop. We know that you cannot have it listen for a key press inside the loop without pausing the loop cycle. We are asking it to record a stroke and make decisions based on what the stroke is. Well, actually, not even the stroke, but hard return, and then based on what was written before the hard return.
Hm. If you try a loop within a getchar loop it’s the same, because the within loop will still just keep going until the conditions are met, and will still pause at getchar as a within condition.
Press a key. Set off an increment. End it with a key.
I guess I could do a function where getchar returns a value, and that value sets off an increment loop. But then I caould do that just as easily with an if. The problem is once the increment starts, how to stop it. Some double blind triple gate.
Apparently I am not the first to have this problem.
The problem is that C is meant to be fairly universal, and a key stroke goes through all kinds of filters before it becomes a character, all of which getchar parses.
All the ways I see seem to require some additional library.
The ones I like most are ones that do what I sort of intuited should be the answer, which is to sort of coopt Ctr C so that it ends a loop rather than the whole program.
Another suggestion I saw was to use several programs, which I thought about, but also angers me because it takes away from the elegance. You want it all in one program, you hit execute once.
And I need an additional library anyway. Probably the more parsimonious solution is to use the time.h library and just make a chronometer. It is said to work within fractions of a second, and if it gives even just decimals of a second it would be fine for my needs. What’s a microsecond? I guess a 100th?
Probably going to do some reading up on that library then. It’s sad, but it’s the kind of inconvenience that speaks well, rather than ill, of C.
Shit is so powerful that it asks “what kind of input?”
subtract program starting time from process time, multiply by character, store as rawnumber
measure amount of digits in rawnumber
divide rawnumber by 1xE(amount of digits) to give arraynumber1
store arraynumber1 without decimals as a[0]
subtract arraynumber1 from 1 and multiply by 10 to give arraynumber2
store arraynumber2 without decimals as a[1]
repeat until number of arraynumbers equals amount of digits
input character, get process time. Repeat previous process but subtracting process time1, instead of program starting time, from starting time2.
Continue until arrays a, b and c are filled with 100 elements each.
Print “thank you you can stop typing now”
Each element of array c is added to the first element of array b and the first element of array a. The total is whittled down by subtration to a 1 or a 0, 1 incrementing heads and 0 incrementing tails. Then the same is done with the next element of array b. When array b is completed, the process repeats with the second element of array a, and so forth.