0

enter image description here

Hi,im new to C programming and i just want to know things !! Im curious about whats the value of line 1, line 5, line 9 and line 13,and whats different between them. Cheers !!

L.Rat
  • 39
  • 6
  • A common tool to answer this question definitively is a "hex editor" (or display mode) or a hex dumper. See if your editor can help you there. This would give the information from a character encoding perspective with byte values in hexadecimal notation. – Tom Blodget Dec 02 '18 at 16:00

2 Answers2

2

It is a new line character \n For example if you have printf("hi\n\nworld"); It will print

hi      // hi and \n
        // just \n   
world   // world

See here for another control characters

Ruslan
  • 6,090
  • 1
  • 21
  • 36
2

The answer depends on your interpretation of the data.

This data file could, physically on the disk, be encoded in multiple ways. Your editor has made an interpretation of its own. It seems that the file consists of character lines, terminated with a newline.

The value you get when reading this file in a C program depends on how it's encoded - how the characters are represented. Most likely it's single-byte characters, ASCII or UTF-8 encoding, but could as well be multi-byte characters, where a single character is represented by multiple bytes. You can examine the byte-level contents of the file using a hex editor.

One thing that often varies is the line termination. In most platforms that would be either '\n' (newline, 0A hex), '\r\n' (carriage return and newline, 0D and 0A hex) or '\r' (carriage return alone).

Judging on how your editor shows a line number in front of the last line, it probably consists of a newline sequence.

You can find a complete answer only by reading in the file in your program line by line and making an interpretation. The value of a line (your interpretation) could then be, for example,

  • A non-empty string or an empty string (including or excluding the line termination)
  • A numerical value or NaN, Not-a-Number
  • A byte sequence

Assuming ASCII encoding and '\n' line termination, the empty lines could be represented as "\n" strings (length 1), or if you discard the newline, "" (length 0).

Sami Hult
  • 3,052
  • 1
  • 12
  • 17