7
I was coming across a code here and I was curious about this excerpt:
FILE *fp = fopen("Agenda.txt","a+t");
What’s the point of "a+t"
?
7
I was coming across a code here and I was curious about this excerpt:
FILE *fp = fopen("Agenda.txt","a+t");
What’s the point of "a+t"
?
8
This is the access mode to the file being opened. "a+" indicates that you can only add data at the end of the file (append) and that can be read as well ("+"). Recording must always be made official with fflush()
.
"t" indicates that you can only use text, but this is not standard C. Only some specific compiler accepts on specific platform, but this is considers a undefined behavior.
How the file is opened with fopen()
, has to be effected using fflush()
.
@Wtrmute yes, I think it was just typo, thank you.
2
According to the website of fopen.
"a+t" or "at+" it opens a text file in read or update mode (adding the new information at the end of the file).
Thank you very much!
The "text mode" refers to the translation of car returns, which it converts when reading from CR LF
for LF
, and the opposite when writing. A flag opposite, b
, explicitly disables this conversion.
Browser other questions tagged c filing-cabinet fopen
You are not signed in. Login or sign up in order to post.
Look, the "t" I don’t know, because I don’t know much
C
. But I can assure you thata
means: "always add content from the last line of the file"– Wallace Maxters
That’s right, thank you!!
– Deborah Assunção
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero