As you say, C was not written to be a "begginers language". With a little bit of experience, you can certainly write a funciton that does "getInt" or "getDouble".
scanf() is a bit of a swiss-army-knife, tries to do many different things, and in doing so, does most of them rather badly. But it is also very powerful, because you can read all sorts of interestingly formatted input with it. For example, a : separated list of username and userid can be read by:
And as to changing it, it won't happen any time soon. scanf() has been part of the C language since it became published (in the original K&R -non-ANSI edition), and it's unlikely to be replaced by something better anytimes soon.Code:scanf("%s:%d", name, &id);
C++ is a little bit user friendlier here, with the cin >> x;
As to the choice of using a char * format string and variable arguments, well, I'm sure we can come up with many different solutions. None of them will be perfect. The only other flexible model would be an array of "descriptors" - each describing one element of input, where to store that and how it is formatted. I don't think that's better.
Using many individual calls to getInt, etc, etc, would be less space-efficient. Perhaps not important today, but in the time when C was invented, saving space was critical - after all, machines would have kilobytes of memory available to a process - not mega- or gigabytes.