@Jerry Coffin @milleniumbug Thank you very much for very detailed explanation, sorry for late response, I slept
Consider this code, http://ideone.com/8txwBg I remember that fgets() is leaving the newline character while gets() is not. It can be seen that scanf does implicitly similar to ungetc('\n', stdin); call That's why the string variable contains 10 ASCII value at index 0
Am I right?
Based on your beatiful detailed explanation, please correct my points
(1) We know that stdin is a pointer to FILE structure (2) the FILE structure will record all the information to manipulate the stream. (3) While the stdin is definitely a stream which came from the keyboard, (4) the stdin stream goes straight into the platform implementation-defined temporary storage
@Jerry Coffin @milleniumbug, am I right?
(5) stdout and stderr came from a distinct platform implementation-defined temporary storage. (6) Both stdout and stderr go straight into the monitor.
Now, in commonly used operating systems, like Windows and Unix derivatives, you can actually make the program actually read the input from another source, for example, from a file. Not only that, you can make it so the output is written to the file.
@milleniumbug yes as you have pointed in (3) also, it musn't be a monitor.
Ah, I see the stdin stream is usually go into the platform implementation-defined temporary storage, but you can change it, such as this command fread(&string, sizeof(string), 1, stdin);
And stdout and stderr is usually came from the platform implementation-defined temporary storage, but you can also change it too
There must be a default condition where do the stdin stdout and stderr came from and go into, such as the platform implementation-defined temporary storage, am I right?
I'm too lazy to read the wall of text on top. What is the question? You probably don't want to change the input/output streams, rather read a file or something similiar?
@Mikhail No, I'm talking about the most very basic concept of standard stream. I'm talking about the possibility, is it possible to change the stdin stdout std source and its destination?
C11 Latest Working Draft N1570 on page 307 at footnote no. 272 state that "272) The primary use of the freopen function is to change the file associated with a standard text stream (stderr, stdin, or stdout), as those identifiers"
Bravooooooooo, beautifulll, I understand now, indeed we can change the implementation-defined temporary storage in order to write or read data from it into any another source.
Recently I have been exploring the enchanted /dev folder. I want to write some random data to an audio device in order to generate some noise.
I am using ALSA.
So I instruct cat to pipe some random data to the playback file in the /dev folder...
cat file-of-random-data > /dev/snd/pcmC0D0p
t...
@Mikhail @milleniumbug Umm, please correct me if I wrong, I think redirection and piping only temporarily switch the platfrom implementation defined temporary storage into any desired storage.
While the actual stdin stdout and stderr temporary does not change at all. Am I right?
Beautiful explanation, so indeed it is also platform implementation defined the me the method of piping and redirecting.
It can be 1. Switch the actual temporary storage stream with the desired one (Does not change the actual temporary storage) or 2. Change the actual temporary storage stream with the desired one, process something, Change it back from the desired one into the actual temporary storage again or anything else
The method is "implementation dependent, magic stuff is done to make pipes fast" hahaha
@Mikhail it's just only the concept of stream that I was trying to understand, it is a wonderful experience indeed lol hahaha
@Mikhail I thought that there is only one type of pointer, after searching a little bit I am wrong.. okay enough for today.. hahahaha
@Mikhail @JerryCoffin @milleniumbug
C11 Latest Working Draft N1570 on page 307 at footnote no. 272 state that "272) The primary use of the freopen function is to change the file associated with a standard text stream (stderr, stdin, or stdout), as those identifiers"
One last thing, does the standard also confirm that the sterr, stdin, and stdout are opened with text stream? or it is platform implementation defined whether it is text or binary stream?
The only thing I can sure is the orientation
Do the compiler writer must follow those standard footnote?
Are you sure that the C11 standard footnotes are not-normative? I can't find in the standard which states like that
I only found this at the introduction section on page xvii "4 Examples are provided to illustrate possible forms of the constructions described. Footnotes are provided to emphasize consequences of the rules described in that subclause or elsewhere in this International Standard. References are used to refer to other related subclauses. Recommendations are provided to give advice or guidance to
"Annexes D, F, G, K, and L form a normative part of this standard; annexes A, B, C, E, H, I, J, the bibliography, and the index are for information only. In accordance with Part 2 of the ISO/IEC Directives, this foreword, the introduction, notes, footnotes, and examples are also for information only.
This one?
It refers to the annexes right?
I can only find 2 paragraph which contains "foot" word in it using CTRL+F
(1) Footnotes are not form a normative part of this standard (2) Footnotes are for information only (3) Footnotes are provided to emphasize consequences of the rules described in that subclause or elsewhere in this International Standard
Hi fellow, i have a problem to control a parallel diagonal, in a matrix 2d, at the principal two by two if one is reverse the other. I'm thinking to help me with a support arrays but it's not the best idea. So i'm asking you help
@m.vincent So what would you do instead? Force every object to be default constructible? Forbid member objects that are not default constructible? Those don't seem like good alternatives.
I am newbie to Driver Development, i installed Visual studio 2015 then Windows Driver Kit(WDK) 10. after that now i am trying to create a hello world KMDF project, follow all the procedure to create new KMDF project in VS2015, but library path is not set, i do not know where is library file is kept. project is not finding "driver.tmh"
instruction means, i create a simple hello world project from, File-> New-> Project->Visual C++->Windows Driver->KMDF Project, after that default source file are there, but it is not able file "driver.tmh"
i know KMDF library is missing, but how can i get library for KMDF?
"267) The three predefined streams stdin, stdout, and stderr are unoriented at program startup."
"272) The primary use of the freopen function is to change the file associated with a standard text stream (stderr, stdin, or stdout), as those identifiers"
So it can also be concluded that (stderr, stdin, and stdout) initial orientation is implementation-defined and whether it is initially text or binary stream is is also implementation-defined?
The ISO/IEC Directive Part 2 on "26.5 Specific principles and rules" section in page 52 said, "A footnote can appear anywhere within the text of a document apart from terminological entries. Footnotes shall not contain requirements (e.g. use of “shall”, see Table 3) or any information considered indispensable for the use of the document, for example ins…
Umm, what if I can't found any requirement which enforce the informative note?
"Each stream has an orientation. After a stream is associated with an external file, but before any operations are performed on it, the stream is without orientation. Once a wide character input/output function has been applied to a stream without orientation, the stream becomes a wide-oriented stream. Similarly, once a byte input/output function has been applied to a stream without orientation, the stream becomes a byte-oriented stream. Only a call to the freopen function or the fwide function can otherwise alt…
> After a stream is associated with an external file
> stderr, stdin, stdout which are expressions of type ‘‘pointer to FILE’’ that point to the FILE objects associated, respectively, with the standard error, input, and output streams.
Yes it does make sense, because the directive part 2 said that it must be a fact, it mustn't be wrong, it must be true,
In my understanding, if something is informative it means it doesn't constitute a requirement, and because of it, the footnotes are platform implementation-defined Am I right?
@milleniumbug Thank you very much sorry for make you busy....
@Unknown123 "Footnotes are provided to emphasize consequences of the rules described in that subclause or elsewhere in this International Standard."
^ from Introduction
@Unknown123 oh, there's a third one
> At program startup, three text streams are predefined and need not be opened explicitly — standard input (for reading conventional input), standard output (for writing conventional output), and standard error (for writing diagnostic output). As initially opened, the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device.
Ahaaaaa, so three of them is initially text streams, NICEEEEEEE
In order to understand the source of footnotes, we must find in the whole standard which state directly to it and it can take a lot of time because ctrl+f might not work well with this