Stepping through a file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Stepping through a file

saridskisaridski Posts: 56Member
Hi there,

I have a file containg this:

aabbccddeeffgg

And i want the following output:

aa
ab
bb
bc
cc
cd
dd
de
..
..

I have tried with the following:

..
while (($n = read(F_IN, $data, 2, $offset)) != 0) {
print "$data
";
$offset += 1;
}
..

But the output looks all wrong:

aa
abb
abcc
abcdd
abcdee
abcdeff
abcdefgh
abcdefghi
abcdefghij
abcdefghijk
abcdefghijk

Can anyone come with some insight? I'd really appreciate it.

Thanks in advance!

saridski.

Comments

Sign In or Register to comment.