Is the new line character part of the same line as the previous character

Why am I asking?

I am given the serious task of reprogramming the GUI widget of a text field AND a type writer, so this is the source of this question.


Current mine approach

Currently, in my project, the new line character \ncontains the position coordinates of the first character on the next line (column1, line + 1). However, I am afraid that this is not a standard understanding of the position of a new line.


Question

Is the new line character \npart of the same line as the previous character, is it part of the next line (as in my current approach), or with none of them?


Does it matter?

, , ( , ), , , - .

+4
2

, \n , () .

+7

7.21.2 " , , . ...."

OP. .


C, '\n'.

5.1.1.2 : "... ( )..."

6.4.9 : "... //... ."

6.10.3 : "... , , #define preprocessing...."

6.10. : " ..."

6.10.4 : " , ..."

C '\n',

7.4.1.10 isspace: "... ... new-line ('\n')..."

5.2.2 "\n ( ) .

-

unsigned long long file_line_count(FILE *inf) {
  unsigned long long line_count = 0;
  int ch;
  int previous = '\n'; 
  while((ch = fgetc(inf)) != EOF) {
    if(previous == '\n') {
      line_count++;
    }
    previous = ch;
  }
  return line_count;
}
+1

All Articles