Why is FILE all-caps as in FILE*? [closed] - c

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
This just seems odd to me, most other things are lower case.
Is there some historical reason?

It's a macro. Macros have historically had all caps in C. Unfortunately recent trends appear to have broken that fact.
Small history lesson: Also, FILE was an io buffer abstraction in UNIX v7 libc stdio. A FILE doesn't necessarily represent a physical file, just something that can do block IO. Source:
http://www.bsdlover.cn/study/UnixTree/V7/usr/include/stdio.h.html
"file" was already defined by the kernel as well:
http://www.bsdlover.cn/study/UnixTree/V7/usr/include/sys/file.h.html
As someone else said here it's probably a typedef now, but I don't think C had typedefs back in '79 as it only just had structs. Then again I wasn't born then so... :)

It's all caps almost certainly because at least originally it was a macro. Nowadays, chances are pretty good that it's a typedef instead, but nobody changed the name to boot (and doing so would be a pretty lousy idea).

Related

Why is the "FILE" data type in C not simply written as "file"? [duplicate]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
This just seems odd to me, most other things are lower case.
Is there some historical reason?
It's a macro. Macros have historically had all caps in C. Unfortunately recent trends appear to have broken that fact.
Small history lesson: Also, FILE was an io buffer abstraction in UNIX v7 libc stdio. A FILE doesn't necessarily represent a physical file, just something that can do block IO. Source:
http://www.bsdlover.cn/study/UnixTree/V7/usr/include/stdio.h.html
"file" was already defined by the kernel as well:
http://www.bsdlover.cn/study/UnixTree/V7/usr/include/sys/file.h.html
As someone else said here it's probably a typedef now, but I don't think C had typedefs back in '79 as it only just had structs. Then again I wasn't born then so... :)
It's all caps almost certainly because at least originally it was a macro. Nowadays, chances are pretty good that it's a typedef instead, but nobody changed the name to boot (and doing so would be a pretty lousy idea).

C if else condition [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In C if i have only one line in the if condition then can i combine it into one line to reduce the size of code. The size of code is long so I intend to take this step to reduce size of code. Should I should I not? Is it a good programming practice?
It makes no sense to be concerned about the size of the sources at the point of sacrificing readability, especially since sources are extremely small compared to almost any kind of other data that our computers usually process/store (e.g. the bzipped sourced of the Whole Firefox are 85 MB - smaller than any medium-length video). Also, omitting a newline won't change the compilation times of a millisecond.
So, if you prefer one-line ifs for your own stylistic reasons it's fine (although it's often frowned upon), but for saving a few bytes it makes no sense at all.
Actually if the code is long then it's not good programming practice as that code will not be as readable.
so it's better to use if else syntax to make your code readable

Is there any compilation of C terminology available on net? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Is there any compilation of C terminology available on net ? I feel it many times difficult to explain in exact technical terms what I wish to say.
Here is a compilation:
C Terminology
C Reference
Basic C
cdecl
cprogramming
CLC-wiki<---got from anon ymous to add
A to Z(C++ but there are helpful common terms)
A to Z(C/C++/C#)
wiki-book
Big tutorial
Tips and Tricks
There really is no substitute for the C Language Standard. The real deal from ISO is pretty expensive, but you can see a late draft at
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
The rationale can also be helpful.
http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf
Half compiled terminology are available at
CLC: terms
Programming Examples
and the best at 3. Terms, definitions, and symbols of C standard.

Why are C names shortened? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Why there is a function called strcat and not a function called stringConcatenation, or stringConcat or string_concat or something like that? Why there is a clrscr function and not clearScreen or clear_screen?
Does it have something to do with source code size in past days, where every byte was worth gold on overly-sized floppy disks? Or is this fueled by programmers' inherent laziness? Is it a convention?
This is partly historical.
In very old C compilers, there was no guarantee that more than the first 8 characters of an identifier name would be used to determine uniqueness. This meant that, originally, all identifiers had to be eight or fewer characters, so method names were all made short.
For details, see Identifiers in the C Book.
When C and its associated tools were first being developed, input devices were not nearly as easy to use as modern keyboards. I've never actually used an ASR-33 Teletype, but as I understand it typing stringConcatenation on such a beast was significantly more difficult than typing strcat (and without autocompletion, you would have had to type the entire name with no typos). It took a substantial amount of pressure to activate each key. Output was also painfully slow by modern standards.
This also explains why common Unix command names are so terse (mv and cp rather than move or rename and copy).
And it's probably also why old linkers only supported such short names. Programmers would generally create short names in the first place, so there was little point in using scarce memory to allow for longer ones.
In addition to all this, there's a case to be made that shorter names are just as good as longer ones. Names of library functions, whether strcat or stringConcatenation (or is it stringConcatenate? String_Concatenate? stringCatenation?) are essentially arbitrary. Ease of typing isn't as important as it once was, but it's still a consideration.

Does C require that variables are declared at start of scope? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
The C language requires that all variables used in the program should be declared before any other statements.
Why was this of significance? Was it for readability? If it was for readability, then why don't other languages follow the same rule?
I personally prefer declaring all my variables at the very start.
Moderators: Please delete if this is off-topic or already been asked. I was just keen to know improve my knowledge. Thanks.
Like other people said in comments now it's not mandatory anymore. Anyway it wasn't for readability. C is a very old language and one of its peculiar features is that a C file can be compiled with just one parsing. I think that the earliest version of the language made the choice to declare variable at the beginning for simplify the parsing

Resources