Thread: Help using cout to format how my statement is suppose to print

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    67

    Help using cout to format how my statement is suppose to print

    Ok first of all, my statement needs to print like this.

    Code:
    Second 0:
       Running: No Jobs
       Queue 0: Empty
    It is a queue which is actually 3 arrays at the moment I just want to print wait[0]

    like this

    Code:
    #include <iostream>
    #include "queue.h"
    
    using namespace std;
    
    int main() {
    
     string jobname;
     int subtime, priority, runtime;
     int itemstoProccess=0;
     const int NUM_QUEUES = 4;
     const int MAX_RUNNING_TASKS = 2;
     const int MAX_INPUT_JOBS = 20;
    
     Queue wait[NUM_QUEUES];
    
     struct RUNNING {
      JOB job;
      int elapsed;
     } running[MAX_RUNNING_TASKS];
    
     struct INPUTJOBS {
      JOB job;
      int priority;
     } inputJobs[MAX_INPUT_JOBS];
    
     while(cin >> subtime>>jobname>> priority>> runtime)
     {
       inputJobs[subtime].job.jobName=jobname;
       inputJobs[subtime].job.runtime=runtime;
       inputJobs[subtime].priority=priority;
       itemstoProccess++;
     }//end while cin
    
    
    
     for( int sec=0; itemstoProccess!=0; sec++)
     {
       cout << "Second "<<sec<<":"<<endl;
       cout << "   Running: "; 
    
       if(running[0].job.jobName=="" && running[1].job.jobName=="")
       {
         cout << "No Jobs"<<endl;
       }
       cout << "   Queue 0: " << (wait[0].displayAll());
       
    
      //wait[0].displayAll();
    
    
    
    
    
    
    
    
    
    
    itemstoProccess--;
    
     }// end sec for loop
    
    
    } // end main
    my displayAll() function is written like this.
    Code:
    void Queue::displayAll()
    {
      if (isEmpty()) cout << "Empty." << endl;
      QueueNode *temp = frontPtr;
    
      while (temp!= NULL) 
      {
        cout << temp->item.jobName;
        temp = temp->next;
      }
    } // end display
    I get this error message:
    error: no match for 'operator<<' in 'std:perator<< [with _Traits = std::char_traits<char>](((std::basic_ostream
    <char, std::char_traits<char> >&)(& std::cout)), ((const char*)" Queue 0: ")) << wait[0].Queue::displayAll()'

    thanks for looking
    Last edited by newbc; 07-15-2011 at 10:37 AM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Your function does the printing. Don't try to print the function, because your function isn't a thing. Just call the function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to format print for Hex like output
    By Teropita in forum C Programming
    Replies: 2
    Last Post: 05-07-2011, 06:59 PM
  2. bizarre print statement glitch
    By spongefreddie in forum C Programming
    Replies: 4
    Last Post: 09-23-2010, 10:39 AM
  3. Displaying 9.8754321 exactly using cout and format flags
    By forumuser in forum C++ Programming
    Replies: 9
    Last Post: 09-30-2009, 02:07 AM
  4. cout format as hex
    By RiPC0rz in forum C++ Programming
    Replies: 4
    Last Post: 02-20-2008, 12:45 PM
  5. How to print the value of char pointers using cout?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 09-21-2005, 04:56 PM