Writing a line to a file longer than 4095 characters

I am creating a distributed messaging system for users to send messages to each other on different Linux terminals. The scenario that I am considering for my question is when I try to write a string to a text file whose length exceeds 4095 bytes / characters. This string will be generated from user input. I read that the ISO C99 standard for maximum string size is 4095 bytes / characters. Should I limit the user to only inputting a string of less than 4095 bytes? I know that simple chat messages are usually short, but the scenario that interests me is as follows.

The user is trying to copy and paste a fragment from somewhere, and then send it to another user. If the message was longer than 4095 bytes, then it will truncate characters after the 4095th char. Thus, the user will receive only the first part.

I'm not sure about this, but I was wondering if I should go along the path of increasing the size of the stack if the line is longer than 4095 characters or is there another way around this, as if breaking the line when I pick it up, and then writing several lines to the file by parts.

+3
source share
2 answers

, "hello world". , . , , 4095 !

+10

"" 4095 . C, , .

+1

Source: https://habr.com/ru/post/1772422/


All Articles