So I've been using this input file and beating myself up because no matter what I did, it would not display properly for me. I did figure out why it was happening but I want to know what the ¤ (Currency symbol) next to the EOL (End of line) ¬ means, and why it isn't easy to add or remove them (¤). I have never came across this problem or seen anything posted about it, primarly because I don't know what the ¤ really is, if I had to take a guess I'd say it is some sort of linebreak or newline. Maybe this is one of those nice Apple bugs in xCode.
Update 3
Input function:
while (!mDataFile.eof())
{
MLSInfo temp;
//mDataFile >> temp.mlsId;
mDataFile >> temp.mlsId;
mDataFile >> temp.salePrice;
mDataFile.ignore();
getline(mDataFile, temp.address);
if (!mDataFile.eof()){
list.listInsertEnd(temp);
}
}
Output function:
DListNode* tempPtr = list.getHead();
while (tempPtr != nullptr) {
MLSInfo temp = tempPtr->dataVal ;
cout << temp.mlsId << " " << temp.salePrice << " " << temp.address << "";
tempPtr = tempPtr->nextNodePtr;
}
Update 2:
Download link of broken file. https://ufile.io/jzyxx
Update 1:
STRING:
00111 75000.00 123 Main Street¤¬
HEX:
30 30 31 31 31 20 37 35 30 30 30 2e 30 30 20 31
32 33 20 4d 61 69 6e 20 53 74 72 65 65 74 0d 0a
UNICODE CODE FOR ¤:
U+00A4
What the output looked like
To fix the problem I just removed all the ¤'s by retyping the input file.
It looks like those light gray Unicode characters are Xcode's way of displaying whitespace characters. The dots are spaces and the arrows are newlines, so I'd guess your currency symbols are carriage returns.
Looking at your hexdump, we see character 0x0d
. Comparing with an ascii table confirms that it is indeed a carriage return.
Since the default delimiter for getline
is a newline*, this carriage return is going straight into your string! This will affect things when you then try to output that string later. (without seeing your code, it's hard to say why it's printing the way it is)
How these could've gotten into your file is a mystery without more information (was the file on a windows machine at some point?), but simply removing them from the file should be enough to solve your problems.
*Realized I'm assuming the use of getline
here because if you were using cin
with the >>
operator, it would stop at any whitespace, including carriage returns.