内存地址打印以及字符串

memory address prints aswell as string?

本文关键字:字符串 打印 地址 内存      更新时间:2023-10-16

我正在尝试打印出数组的内容,但是它也打印每个元素的内存地址,然后打印元素。

void generateEndOfDayReport(taxiDetails taxiDataStore[], fareDetails reportArray[])
for (int i = 0; i < 14; i++)
        {   cout << "Here is a list of the taxi drivers in ascending last name order: " <<
            cout << taxiDataStore[i].taxiDriverSurname << endl << "And here is the money they took in over the course of today: £" <<  taxiDataStore[i].fareDetailsForTaxi.overAllFareDetails << endl << endl;
        }![enter image description here][1]

从你的代码来看,你有一个错别字,它写着:

cout << some-text << cout << variable << endl << some-more-text << variable << endl << endl;

请注意,您正在将cout流式传输到 cout 中。这真的是你的意图吗?