मैं आउटपुट को लंबे समय तक कंसोल में प्रारूपित करने का प्रयास कर रहा हूं और वास्तव में कुछ भी नहीं हो रहा है। मैं iomanip
जितना अधिक कर सकता हूं और ofstream&
फ़ंक्शंस के रूप में उपयोग करने का प्रयास कर रहा हूं।स्वरूपण सी ++ कंसोल आउटपुट
void list::displayByName(ostream& out) const
{
node *current_node = headByName;
// I have these outside the loop so I dont write it everytime.
out << "Name\t\t" << "\tLocation" << "\tRating " << "Acre" << endl;
out << "----\t\t" << "\t--------" << "\t------ " << "----" << endl;
while (current_node)
{
out << current_node->item.getName()// equivalent tabs dont work?
<< current_node->item.getLocation()
<< current_node->item.getAcres()
<< current_node->item.getRating()
<< endl;
current_node = current_node->nextByName;
}
// The equivalent tabs do not work because I am writing names,
// each of different length to the console. That explains why they
// are not all evenly spaced apart.
}
उनके कुछ भी है कि मैं पाने के लिए यह सब ठीक से एक दूसरे के साथ गठबंधन का उपयोग कर सकते है? जो फंक्शंस मैं कॉल कर रहा हूं वे स्व-व्याख्यात्मक और विभिन्न लंबाई हैं, ताकि एक-दूसरे के साथ बहुत अच्छी तरह से संरेखित न हों।
मैंने iomanip
में बस सब कुछ करने की कोशिश की है।
मानक कब manipulators (setw और अल), +1 एक कस्टम iomanip परिभाषित करने के लिए लिए +1, एक्सेल – outis
के लिए और -1 आप भी स्ट्रिंग के आकार को सीमित कर सकते हैं सिर्फ मामले में मुद्रित करने के लिए आप बड़े हो तार (जैसे पूर्ण नाम) – Vargas