В C, как записать, какой бы ни конец символа строки соответствует ОС?

Вы можете сделать это несколькими способами:

Наиболее очевидным решением будет запись атрибута onclick в элементе кнопки.


или другим способом является добавление прослушивателя событий к кнопке

document.getElementById("button").addEventListener("click", function() {
  alert("Button Clicked");
});

Также проверьте Ссылка jsfiddle для работы: https://jsfiddle.net/tkfbg0dw/4/

, дайте мне знать, если вам нужна помощь. Благодаря

7
задан Rob Kam 22 April 2009 в 16:35
поделиться

3 ответа

fprintf(your_file, "\n");

This will be converted to an appropriate EOL by the stdio library on your operating system provided that you opened the file in text mode. In binary mode no conversion takes place.

12
ответ дан 6 December 2019 в 05:43
поделиться

From Wikipedia:

When writing a file in text mode, '\n' is transparently translated to the native newline sequence used by the system, which may be longer than one character. (Note that a C implementation is allowed not to store newline characters in files. For example, the lines of a text file could be stored as rows of a SQL table or as fixed-length records.) When reading in text mode, the native newline sequence is translated back to '\n'. In binary mode, the second mode of I/O supported by the C library, no translation is performed, and the internal representation of any escape sequence is output directly.

12
ответ дан 6 December 2019 в 05:43
поделиться

When you open a file in text mode (pass "w" to fopen instead of "wb") any newline characters written to the file will automatically be converted to the appropriate newline sequence for the system. Newline sequences will be translated back to newline characters when you read the file.

This is why it's important to distinguish between text and binary mode; if you're writing in binary mode, C will not tamper with the bytes you write to a file.

9
ответ дан 6 December 2019 в 05:43
поделиться
Другие вопросы по тегам:

Похожие вопросы: