I find "programming" a constant distraction from electronics in some "tutorials" - Page 1
Forum section: electronics / general

author: eti
author_rank: Super Contributor
timestamp: September 21, 2020, 05:20:36 pm
content: Go to any random internet "tutorial" for some aspect of electronics, and you're almost certainly going to see"Here's my github >>"and/or"... and I've written some code here for..."Whilst I admit that it's not unreasonable to expect to have to write *some* code once in a while, when your main area of experience or expertise is hardware, and not software, I find it *incredibly* distracting to constantly be led down the"now let's look at the Arduino code for this...".Case in point is a function generator I am playing with - the AD9833 module. I want to generate waves, not sift through Arduino code learning syntax and work out what's what in an IDE, debug dodgy UART drivers etc... yeah I get that I can BUY a func gen, but I don't have the funds right now, and this board suffices just nicely. I want to generate ANALOGUE waves for an ANALOGUE circuit, not learn a new paradigm in a different area - it's SO DISTRACTING.What did people do before Arduino and microcontrollers were the go-to "solution" (lazy solution) for almost EVERY project online, if they wanted to generate waveforms? They'd learn to build **a circuit** using electronics skills, not some random programming languagewhich has nothing whatsoever to do with the circuit!This is where laziness shows up in our engineering society - no one's willing to invest the time and work in a project (incuding me btw, often) so they tack together a "solution" which makes the project dependant on some microcontroller or board - that DOESN'T teach us electronics fundamentals. I am learning *electronics*, not Arduino. Is there anyone left whom publishes clear tutorials to show one how to make such circuits in a "Mr Carlson's Lab" kinda way (IE, clear, slow and calm) without resorting to uC's?Thanks.

author: fourfathom
author_rank: Super Contributor
timestamp: September 21, 2020, 05:34:41 pm
content: Do you want fundamentals, or do you want working projects? There is a difference, especially when the practical solution uses devices that require a control interface.Look at ham radio projects if you want to build something using simple (non-programmable) components, There are still a lot out there that require some design finesse and use traditional parts.

author: pidcon
author_rank: Contributor
timestamp: September 21, 2020, 06:01:51 pm
content: All the hassle from balancing learning programming and other hardware stuff is good for the future. It's natural to want things to be put together as quickly as possible. A 100% analogue solution will take longer to produce and be less flexible.

author: Buriedcode
author_rank: Super Contributor
timestamp: September 21, 2020, 06:05:20 pm
content: Quote from: eti on September 21, 2020, 05:20:36 pmThen ... don't read that persons project/blog/tutorial ? Because it is so easy to post projects and ideas on many platforms, there's so many, of varying levels of complexity and quality, that it is up to you to find one that you are interested in and suits your needs. People provide this information for free, and whilst many may be overkill on micro usage, you don't have to read their code...Quote from: eti on September 21, 2020, 05:20:36 pmSoyoufind it distracting, and frustrating that people haven't formatted or designed their projects in a way you want. If you want to build an analogue function generator, then google "analogue function generator"Quote from: eti on September 21, 2020, 05:20:36 pmDepends how far back you go. 15 years? a PIC, or an 8051 were used if the project required control or computation beyond what raw logic could do. Analogue isn't dead, the real world is analogue.It's just the low cost, convenience, ease of use etc.. of the Arduino platform - and these days, microcontrollers in general - has lowered the bar for "just use a micro". Perhaps 20 years ago, folks would use a handful of TTL or CMOS glue logic, and a load of analogue, which took time to prototype, debug, lay out etc.. But not for about $3 you can have a small breadboard friendly module that you can program and debug in 20 minutes that is capable of far more than the "old" way. It is simply, quicker, cheaper, and easier for many projects. Welcome to the 21st century.I understand that "just throw an Arduino at it" is a bit boring and doesn't show other solutions, but surely you can see why that is the case? The only people going out of their way to avoid micros or FPGA's or modern IC's are those trying to build vintage/legacy hobby projects. You can still find plenty of old school schematics if you want to do things in a different way, and you can still buy many of the parts - so whats the problem?Quote from: eti on September 21, 2020, 05:20:36 pmAlso remember, the projects you see online (hackaday, instructables etc.. are often one-off hobby creations. It's about knocking something up quick, with the parts you have, not always cheap, and certainly not always robust or well engineered, so why do you assume that they should be perfectly engineered? It's like looking at A-level art projects and complaining about them not being a Turner.Electronics is so much more accessible with the internet. Decades ago, whilst you could of course buy kits, and read books, it was still a bit of a niche, and was relatively expensive. As books cost a fair bit to publish, the quality of the information was somewhat higher than the internet - where you can literally post anything, regardless of validity, and it goes unchecked. We all learned this lesson in the 90's, and it is up to you to separate the wheat from the chaff.Seriously, it just sounds like you're complaining that you're searching for projects that you either don't understand or don't like because they don't do things the way you think they should. And they provide them to you, for free, it is up to you to sort through them.

author: ebastler
author_rank: Super Contributor
timestamp: September 21, 2020, 08:10:46 pm
content: Quote from: eti on September 21, 2020, 05:20:36 pmUmm... You did realize that the AD9833 is aprogrammablewaveform generator, did you? To use it, you might want to program it -- surprise! So I am not sure what you are complaining about. (Well, but that's true for most of your posts...)May I recommend tube amplifiers as your next project? Less likely to encounter that pesky programmable stuff there.

author: Ian.M
author_rank: Super Contributor
timestamp: September 21, 2020, 08:15:28 pm
content: Just imagine how many eurocards full of TTL logic you'd need to set up all the parameters for the AD9833 on rotary hex switches and dip-switches, and serialize the data as sequenced SPI frames, all without using any MCUs, programmable logic or other programmable devices! Maybe just build an 8 bit serializer and use manually punched cards to program it?

author: james_s
author_rank: Super Contributor
timestamp: September 21, 2020, 09:47:40 pm
content: The vast majority of interesting parts on the market today require some amount of programming in order to configure and control them. If you are not interested in programming then good old fashioned analog design still works, but it's kind of esoteric these days. You might study the app notes and books Jim Williams wrote, he was one of the best analog designers around.

author: tszaboo
author_rank: Super Contributor
timestamp: September 21, 2020, 10:25:58 pm
content: Quote from: james_s on September 21, 2020, 09:47:40 pmI dont think that he is talking about that. I recently watched a micropython tutorial, where the presenter spent 5 minutes explaining what a GPIO is. It is very distracting. And (I think) the reason is that the majority of audience and presenters are programmers and not EEs. It seems to be rewarding that they can blink an LED, or read I2C data from some Adafruit or other sensor. Compare how many tutorials there are on opamps vs ie the BM280 sensor.But let's just stay with the AD9833. You could create an AM radio from it. Or a LRC meter. Or an ultrasonic weld joint inspector. But no, all the first results are playing sine wave music with an arduino. Or a function gen. I personally used it to generate test signal to measure battery ESR.Yet there is only like 1 video, named "dds IC AD9833 shortwave reciever 1" which actually uses it to do something. 700 views. "AD9833 DDS Based Resonance Meter for TESLA Coils and Function Generator (Software Configurable)" 11 views. The videos that are getting the views are just messing around with it.

author: ucanel
author_rank: Regular Contributor
timestamp: September 21, 2020, 10:29:21 pm
content: Quote from: Buriedcode on September 21, 2020, 06:05:20 pm+1You may also try Ben Eater's channel:https://www.youtube.com/c/BenEater

author: eti
author_rank: Super Contributor
timestamp: September 21, 2020, 11:26:04 pm
content: Quote from: NANDBlog on September 21, 2020, 10:25:58 pmIt speaks volumes that only ONE person "gets" what I am on about. Thank you for speaking up, and not allowing the majority to imply I am retarded, or "stupid" for thinking how I do.Many, many years, an old boss of mine told me"the TRUE component-level, electronics fundamental designers are a rare breed - now it's all module-pluggers who call themselve 'electronics engineers' when all they know how to do, for the most part, is copy blocks and plug them together"- I recall having brought up this conversation (this was the 90s) - boy was he ever right!

author: eti
author_rank: Super Contributor
timestamp: September 21, 2020, 11:26:48 pm
content: Quote from: ucanel on September 21, 2020, 10:29:21 pmYes, thank you, I find him fantastic.

author: eti
author_rank: Super Contributor
timestamp: September 21, 2020, 11:40:42 pm
content: Quote from: ebastler on September 21, 2020, 08:10:46 pmClearly...hehe

author: Brumby
author_rank: Unknown
timestamp: September 22, 2020, 12:50:18 am
content: I get what you are saying, but the world has moved on to the point of incredible complexity. This has resulted in specialisation becoming absolutely necessary to produce the best results for any given corner of technology. Flexibility has become a prime consideration in just about any design you might care to think about in pretty much every market segment - retail, commercial, industrial, aerospace or whatever - and this has brought us the modular units (such as Arduino) which can provide this flexibility. As mentioned above, configuration of these modules is what allows a set hardware configuration to perform a variety of functions - and since these functions are so wide and varied, this configuration has also become complex.Here is where we take the configuration process into a much bigger world - and call it programming.We have moved on from digging ditches with pick and shovel to where big hydraulic machines are found everywhere. Certainly, the pick and shovel still have a place, but you will find them special cases, rather than widespread use. Such is the case for this day and age in the world of electronics.Today, we stand on the shoulders of giants where the giants worked with the design details that created the modular tools and it is these modular tools that provide the means to produce the required outcome.One sad aspect of this is that the analogue nature of circuits is getting lost and those all-important principles that apply are often only addressed as an after-thought when things don't work as expected. The general response is that the module designers step up the performance of their modules so that the plug and play approach works as expected, which just affirms the concentration of "true" electronics design skills into the speciality of module development.This is where we are today ... and, as I see it, it won't be going in any direction other than further down the same path.Anyway, just think of microprocessor based circuits as requiring a high level of configuration.

author: fourfathom
author_rank: Super Contributor
timestamp: September 22, 2020, 01:42:57 am
content: I think eti was trolling (and I was the first to bite)

author: greenpossum
author_rank: Frequent Contributor
timestamp: September 22, 2020, 01:45:05 am
content: First, build a time machine. With non-programmable components naturally.

author: eti
author_rank: Super Contributor
timestamp: September 22, 2020, 01:46:26 am
content: Quote from: blueskull on September 22, 2020, 01:39:27 amSorry that my curiosity doesn't meet your approval.

author: eti
author_rank: Super Contributor
timestamp: September 22, 2020, 01:49:39 am
content: Quote from: fourfathom on September 22, 2020, 01:42:57 amAh that old chestnut, where a question or topic outside a limited range of expected lines of enquiry, is seen to not "conform" to some arbitrarily decided-upon "format", and so some random person decrees them as "trolling", simply because that's the easiest thing to attribute to someone not behaving in the manner they're used to.I'm inquisitive, I ask questions that don't always fit your expectations, I expect more of a forum rammed to the rafters with highly intelligent engineering folk than to resort to such lazy, idiotic categorisation.Okay so YOU think I'm a troll, fine. Leave the thread then.That's very intelligent indeed, eh.This is the kind of binary yes/no dipshit, over-simplified "logic" that the supposed "community" of the internet has brainwashed some people into choosing as a go-to attribution for something that doesn't fit in anywhere they're not expecting l, or aren't suitably humble enough to step back, look at objectively and then try to answer SANS ad-hom.I suppose I may overestimate people sometimes eh?Think as you wish of me, it makes not one solitary jot of difference to meYou may like to take a few moments to examine this somewhat intelligent look at why "trolling" is vastly overused:https://theweek.com/articles/445615/time-kill-word-troll

author: fourfathom
author_rank: Super Contributor
timestamp: September 22, 2020, 02:01:05 am
content: Quote from: eti on September 22, 2020, 01:49:39 amOK, so you're not trolling. After a while I was thinking "walks, quacks, etc.", especially after your previous "Clearly...hehe" comment, but I guess not this time. I did give a sincere to your question answer so why don't you cool down?

author: eti
author_rank: Super Contributor
timestamp: September 22, 2020, 02:04:02 am
content: Quote from: fourfathom on September 22, 2020, 02:01:05 amHow are you able to ascertain whether or not I'm calm?I always talk in this precise manner, so as to leave no ambiguity as to my meaning. Yeah it doesn't always work though, hah!Appreciate your intentions in trying to "calm" me - I'm as tranquil and still as the dead sea

author: vk6zgo
author_rank: Super Contributor
timestamp: September 22, 2020, 03:18:36 am
content: Quote from: eti on September 21, 2020, 05:20:36 pmThis sort of thing has been going on since at least the mid 1980s, when I had to produce a project as part of my "Bridging training " to become a "Techical Officer"(Yesterday, I couldn't spell Teknickle Ossifer--now I are one!)The requirement was for an audio signal generator, which, if you rang a particular phone number, would connect to a broadcast programme line & generate a standard set of audio tests.All the (then), "micro processor" enthusiasts said:-"Just use a micro".Apart from all the peripherals needed in those days, I would have had to learn programming.The audio quality available from either generating the tone digitally, or using special analog chips was quite poor, so I ended up with a commercially made switched oscillator.I replaced the mechanical switches with 4066 bilateral switches for frequency steps, & relays for output levels, etc.(the latter done with external attenuators & terminations)These were all switched via a diode matrix, fed from a couple of 4017 decade counters, clocked by a 555, which, in turn, was triggered by a commercial (actually in-house designed) device to detect the original phone call.All my stuff worked, but the settling time of the Wien bridge oscillator in the audio generator was too long.Had I used a "micro", I would probably still been designing it!

author: Circlotron
author_rank: Super Contributor
timestamp: September 22, 2020, 03:25:09 am
content: Quote from: eti on September 21, 2020, 05:20:36 pmThey'd use a 555 instead to flash a LED. And they were lauded as geniuses, of course.

author: ebastler
author_rank: Super Contributor
timestamp: September 22, 2020, 04:38:16 am
content: Quote from: eti on September 21, 2020, 11:26:04 pmIndeed, it does.

author: vk6zgo
author_rank: Super Contributor
timestamp: September 22, 2020, 05:16:25 am
content: Quote from: Circlotron on September 22, 2020, 03:25:09 amWho uses a 555?Self flashing LEDs have been around for decades!I greatly prefer to use a 90v battery, a capacitor, & a resistor to flash a neon, anyway!

author: Circlotron
author_rank: Super Contributor
timestamp: September 22, 2020, 05:30:33 am
content: Quote from: vk6zgo on September 22, 2020, 05:16:25 amYour skillz will be in demand in a post apocalyptic world.

author: ucanel
author_rank: Regular Contributor
timestamp: September 22, 2020, 07:07:32 am
content: Quote from: eti on September 21, 2020, 11:26:48 pmSo what about Apliied Science channel,i think you also like his work to.https://www.youtube.com/c/AppliedScience

author: bsfeechannel
author_rank: Super Contributor
timestamp: September 22, 2020, 05:03:24 pm
content: Quote from: Circlotron on September 22, 2020, 05:30:33 amWill?

author: hugo
author_rank: Regular Contributor
timestamp: September 22, 2020, 11:28:16 pm
content: Sorry, I don't know the answer ...

author: eti
author_rank: Super Contributor
timestamp: September 23, 2020, 12:00:18 am
content: Quote from: hugo on September 22, 2020, 11:28:16 pmBravo, what concise wit you show.

author: Mecanix
author_rank: Frequent Contributor
timestamp: September 23, 2020, 05:31:04 am
content: In contrast; I am relatively new to electronics 'aka' nowhere near the average skilled EE. Still a whole lot to learn before being able to design fully functional analog circuits all by myself. Thanks to modern tech and online knowledge sharing I've somehow managed to get things going the way I wanted, and that is primarily because of the programming background and experience I have (15+ years now?). E.g. without programmatically implementing some sort of clock/timing and switching logic, my circuit wouldn't be half operational at present.So.. yea, far more fancy ICs and jtag TPs than actual passives and traces in my case :/ Parts cost is double also.To each his/her own I'm guessing. Good luck with the transition from analog to digital

author: vk6zgo
author_rank: Super Contributor
timestamp: September 23, 2020, 09:12:59 am
content: Quote from: Circlotron on September 22, 2020, 05:30:33 amThe problem is, where would I find a 90v battery, unless some boxes of 9v batteries survived, so I can "series 'em up!"

author: tggzzz
author_rank: Super Contributor
timestamp: September 23, 2020, 09:18:48 am
content: Quote from: eti on September 21, 2020, 11:26:04 pmI heard that manydecades(not years) ago, in the 60s and 70s. Context: digital integrated circuits, opamps, and pre-assembled modules.If only one person gets what you are on about, then obviously you have not expressed your position clearly enough.

author: bsfeechannel
author_rank: Super Contributor
timestamp: September 24, 2020, 12:18:03 am
content: Quote from: Circlotron on September 22, 2020, 03:25:09 am555 was for the weak. Real men flashed their leds with unijunction transistors.

author: vk6zgo
author_rank: Super Contributor
timestamp: September 24, 2020, 04:38:35 am
content: Quote from: bsfeechannel on September 24, 2020, 12:18:03 amBah! Humbug!If you absolutely have to flash LEDs, like a barbarian, instead of neons like a civilised person, you should use an astable MV using BC108s, or maybe even OC71s.I'm pretty sure you could get a 12AT7 to work at lower voltages, too.A couple of relays back to back might work, ------ but a bimetallic strip would be even better.As for 555s,-----------they were regarded as "so easy, even caveman can do!"No plaudits were awarded there.More like, "Well, duhh!"

author: Circlotron
author_rank: Super Contributor
timestamp: September 24, 2020, 05:34:54 am
content: Quote from: vk6zgo on September 24, 2020, 04:38:35 amLuxury!Back in my day we did it with contacts driven by clockwork.And incandescent bulbs.None of this LED rubbish!

author: fourfathom
author_rank: Super Contributor
timestamp: September 24, 2020, 06:03:08 am
content: Quote from: Circlotron on September 24, 2020, 05:34:54 amWhen I was a young lad we used Leyden Jars and carbon arcs, like God intended.

author: greenpossum
author_rank: Frequent Contributor
timestamp: September 24, 2020, 06:07:56 am
content: Bah I used motor, acetylene flame and Fresnel lens. 🤣

author: Unknown
author_rank: Unknown
timestamp: September 24, 2020, 04:09:53 pm
content: I get your point. A good idea would be for people to say "If you're not interesting in the programming side, click here. Although you might struggle without it" but at least they give the option to skip.It's a lot like forums. I thought it was just me but others have said the same. You ask a question and would like an answer, the angry rant can come at the end.So you askHow do I do A, I know I can do it other ways but how would I do it this way.And annoyingly get"You shouldn't be doing it that way you should be doing it this way blah blah".It's annoying. Just answer my question first then added "But, really you should be doing it this way".Perfect example was my question about plaster powder recently. In the UK we have a shortage but I still need to plaster my small room at some point so am perfectly entitled to buy some. So I grabbed some bags before they all disappeared again. I then had a thought, the powder has a end of life date, what if I put it in a air time bucket, would it mean the plaster lasts longer. So I asked this simple question. The first response was roughly"Why are you buying the plaster now if not using it straight away. There are some of us unable to complete jobs because people like you are buying the plaster up when you're not about to do a job. Don't buy the plaster until you're ready to do the job".Answer my question first THEN have your rant. Thankfully someone did with"It wouldn't work because as you put the powder in the bucket, moisture will also be trapped in the airtight seal which will still make the plaster go off".Simple. I'm an IT engineer and you see it a lot in my profession, people wondering off instead of sticking to the topic.

author: bobcat2000
author_rank: Regular Contributor
timestamp: September 24, 2020, 06:56:12 pm
content: You can skip the first 10 - 20 pages from google. Google shows you the most popular topics. Start from page 20, you may find what you are looking for. It depends on how you search google.

author: rstofer
author_rank: Super Contributor
timestamp: September 24, 2020, 09:38:11 pm
content: Quote from: steviefaux on September 24, 2020, 04:09:53 pmProbably because most of us want to get something working while still young enough to use it. There's a reason that almost every project seems to involve an Arduino and that is because it interfaces well with the world and the user.In the OP, the device was CHOSEN to be an AD9833 knowing, actually knowing, that it has to be controlled via a 3 wire interface with a protocol like SPI. Is there some analog way to create waveforms? Sure! But it won't use the AD9833. If the device choice is cast in stone, it will be controlled by a uC. Arduino or 'other' is another choice but it's likely that the Arduino already has a library.Get the project working in the shortest amount of time with the least amount of effort. That's the plan!The electrical part of the project is trivial but the device control and user interface are not. For a decent interface, figure a couple of dozen SSI chips (to handle rotary encoders, LCD display, etc, and maybe more but you would still wind up building the better portion of a CPU in order to handle the SPI part. Could this get to 100 SSI chips? I wouldn't be surprised! It depends on the features. Personally, I gave up wire-wrap projects a long time back. Code is so much easier to change.Modern projects enjoy feature creep. We can do things with uCs that simply weren't possible 50 years ago, The cost of the performance enhancement and feature creep is code. Lots and lots of code.The code describes the features of the project, the electrical schematics say nothing. Of course the code is presented early! It's the only thing that matters.

author: vk6zgo
author_rank: Super Contributor
timestamp: September 25, 2020, 01:51:37 am
content: Quote from: greenpossum on September 24, 2020, 06:07:56 amIn 1971, I visited the lighthouse near John O'Groats in Scotland.To my amazement, the lamp was an oil burning one, & the light was rotated by a clockwork mechanism.A weight was wound up from the bottom of the tower each day, & the mechanism rotated thelamp all night.At the time, most Oz lamps were either electric or gas operated.What the heck!It worked, & well, too!

author: Brumby
author_rank: Unknown
timestamp: September 25, 2020, 02:27:53 am
content: Bah! I had a hole in the roof of my cave.I got a flashing light at one cycle per day (except when it was overcast).

author: fourfathom
author_rank: Super Contributor
timestamp: September 25, 2020, 02:34:29 am
content: Quote from: Brumby on September 25, 2020, 02:27:53 amThat's 11.574~ microHz. Try doing that with a leaky electrolytic RC multivibrator!

author: pickle9000
author_rank: Super Contributor
timestamp: September 25, 2020, 02:57:45 am
content: How many ways can you flash a light or LED. There has got to be a YouTube video on that.

author: Circlotron
author_rank: Super Contributor
timestamp: September 25, 2020, 05:11:31 am
content: Quote from: Brumby on September 25, 2020, 02:27:53 amHmmm.... I was going to say I had a wooden crankshaft turned by hand that pumped two wood and leather bellows that alternately puffed on two campfires.

author: greenpossum
author_rank: Frequent Contributor
timestamp: September 25, 2020, 05:36:12 am
content: Ha, I turned on the universe at the big bang and it will blink out in a few tens of billion years. Top that.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 25, 2020, 07:24:03 am
content: Quote from: steviefaux on September 24, 2020, 04:09:53 pmIn 97% of the cases of this I've seen (at SO and elsewhere),A is incorrect.If you were to ask me the question via e-mail, I'll answer the way you suggested (ie., the description of how to do A, followed by why it is the wrong way).On the web, on forums where you have dozens or hundreds of lurkers to each asker/answerer, doing that leads to misunderstanding and spreading false knowledge.That is why I for one won't do it in public; I'll always start with "No, that's the wrong way, because Z." It has very little to do with the asker, and a lot to do with those others who read the question and answer.The 3% of the cases are where the OP names the correct method, and gives a sane reason why they don't want/cannot do it that way.In 2% of cases, their belief is incorrect, and the reason they believe they cannot do it the correct way actually does not preclude them from doing it the right way, they just believe so for wrong reasons. The 1% of cases are nefarious (in programming, meaning intrusion or hacking attempts without any real-world use cases).In my experience (of a few tens of thousands of programming questions in the last decade), that leaves only an occasional exception to the rule. (I recall exactly two of such exceptions, both of which lead to a private e-mail exchange to solve the actual issue.) I claim that while this (not answering questions with incorrectAin public) may annoy you, overall it leads to a better world, and is therefore preferable.As to myself and teaching materials, I prefer modularity over a fixed lesson plan (or a "tutorial" video). Just like when giving a (good) presentation, you must tailor the content to best fit the audience. A good work log, in my opinion, would consist of a "tree" of content, with detail videos split into 1-2 minute clips. For those who want to view all the videos at once, one can provide a playlist.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 25, 2020, 07:43:08 am
content: As a practical example of such an incorrect question, here is one that I once again encountered today:I need to implement a C function, that reads a file into memory. It works perfectly in Windows, but fails in Linux, BSDs, and Mac OS with character devices, FIFOS (named pipes), proc/sys pseudofiles, etc. How can I fix fseek() to work with character devices and FIFOs and pseudofiles?The answer is, you don't. You cannot. The entire approach is completely wrong. You cannot and should not expect to always know the exact size of your input beforehand; that is unrealistic in general. You can only determine it for static files (files not being modified concurrently). That approach may suffice in Windows because of its device/filesystem model, but it definitely does not suffice in most other operating systems.The correct answer is to simply read the incoming data into a dynamically allocated and reallocated buffer, until you either determine there is too much data to process, or you encounter EOF (end of input).Hereis an example implementation written in ANSI/ISO C89 (with intent on understandability and maintainability, not efficiency).If you look at the above question, and its accepted answer, you'll see it implements the fseek()/lseek() approach, which is unreliable. (Not only will it fail for non-file filesystem objects like character devices, it will also fail if the file is modified or appended to while being read.) If everyone did like steviefaux demanded and just answered the question without pointing out the error in the question, we'd all still live in third world conditions, eating mud and slinging excrement at each other.

author: bsfeechannel
author_rank: Super Contributor
timestamp: September 26, 2020, 06:37:17 am
content: Quote from: greenpossum on September 25, 2020, 05:36:12 amOK, God.Quote from: rstofer on September 24, 2020, 09:38:11 pmYeah. We have to go with the times. Although I love old school electronics, in my computer I have for free now things that I could only dream of a few decades ago as it would have cost me an arm and a leg. And even though I can have them for cheap these days, now they're obsolete, I wouldn't (with a few exceptions) because they're cumbersome compared to what I can have with the modern technology.This trend of having programming alongside "pure" electronics is not new. Back in the 1970s, formal high school electronics education already included programming as part of the curriculum.