Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

can someone edit my c++ code where it will output to a file in xcode #include iostream #include fstream // For file operations #include string.

can someone edit my c++ code where it will output to a file in xcode

#include <iostream>#include <fstream> //For file operations#include <string.h> //For string comparisionsusing namespace std;struct StockNode{ //Creating of linked list node structure   char itemname[20];   char itemnumber[5];   char quantity[3];   char price[6];   char safestock[3];   struct StockNode *link;};

class InventoryStock //Class for operations and members{   StockNode *head;   public:       InventoryStock() //Constructor default       {           head=NULL;       }       void addStockNode(StockNode *nn) //Add node method       {           StockNode *temp=NULL;           if(head==NULL || strcmp(head->itemname,nn->itemname)>=0)   // Adding first node whether null or head node smaller than nn           {               nn->link=head;               head=nn;               return;           }       temp=head;       while(temp->link!=NULL && strcmp(temp->itemname,nn->itemname)<0) //Traverse upto null before or find a node which is > than new node nn       temp=temp->link;       nn->link=temp->link; //If found insert in its sorted location       temp->link=nn;       }                                   void traverse() //To display sorted list       {           StockNode *temp=head;           cout<<"nNames of Items : "<<endl;           while(temp!=NULL)               cout<<temp->itemname<<"->";       }   };     int main()   {     InventoryStock i1;   StockNode readstock;   ifstream ifile;   ifile.open("Invent.txt"); //Open file for reading     while(!ifile.eof()) //Read until eof   {      ifile>>readstock.itemname>>readstock.itemnumber>>readstock.quantity>>readstock.price>>readstock.safestock; //Read each record of file        i1.addStockNode(&readstock); //Add to sorted linked list   }   ifile.close(); //Close the file   i1.traverse(); // Traverse list   return 0;}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question