On 6/3/20 2:23 PM, BoQsc wrote:
C:\Users\vaida\Desktop\Associative Array Sorting> rdmd testingGround.d
0. The quick brown fox jumps over the lazy dog
nonononoahahahaha Sphinx of black quartz, judge my vow.
2. # How vexingly quick daft zebras jump!
3. # The five boxing wizards jump quickly
4. # Maecenas consectetur risus a lacus sodales iaculis.
5. # Morbi sed tortor sollicitudin, pharetra massa egestas, congue massa.
6. # Sed sit amet nisi at ligula ultrices posuere quis nec est.
7. # Mauris vel purus viverra, pellentesque elit id, consequat felis.
Here you can see ". hahahahahahaha" and "nononono" and even lineNumber
is being merged into the same position. Why is this happening and can
this be simply resolved?
testingGround.d
import std.stdio;
import std.algorithm;
int lineNumber;
void main(){
File exampleFile = File("exampleText.txt");
lineNumber = 0;
foreach(line; exampleFile.byLine){
if (line == " Sphinx of black quartz, judge my vow.\u000D"){
writeln(lineNumber, ". hahahahahahaha", line, "nononono");
} else {
writeln( lineNumber, ". ", line);
}
lineNumber++;
}
}
exampleText.txt
The quick brown fox jumps over the lazy dog
Sphinx of black quartz, judge my vow.
# How vexingly quick daft zebras jump!
# The five boxing wizards jump quickly
# Maecenas consectetur risus a lacus sodales iaculis.
# Morbi sed tortor sollicitudin, pharetra massa egestas, congue massa.
# Sed sit amet nisi at ligula ultrices posuere quis nec est.
# Mauris vel purus viverra, pellentesque elit id, consequat felis.
\u000D is a carriage return, which means that the terminal moves the
insertion point to the front of the line, and writes "nononono" over the
original text there. (BTW, you can just do \r instead)
How do you fix it? I don't know what your requirements are. I don't know
what you are expecting.
-Steve