4 replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
source | link

Possible Duplicate:
Why isn't the line count in Visual Studio zero-based?Why isn't the line count in Visual Studio zero-based?

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

Possible Duplicate:
Why isn't the line count in Visual Studio zero-based?

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

Possible Duplicate:
Why isn't the line count in Visual Studio zero-based?

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

3 insert duplicate link
source | link

Possible Duplicate:
Why isn't the line count in Visual Studio zero-based?

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

Possible Duplicate:
Why isn't the line count in Visual Studio zero-based?

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

    Post Closed as "exact duplicate" by ChrisF of
    Tweeted twitter.com/#!/StackProgrammer/status/116089258170793984
2 deleted 2 characters in body
source | link

Why isn't the firsttop line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the firsttop line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

Why isn't the first line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the first line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

Why isn't the top line in a source code file labelled line number 0?

i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep, awk, sed etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.

It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!

I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.

1
source | link