K
K
kytcenochka2018-05-04 09:58:45
C++ / C#
kytcenochka, 2018-05-04 09:58:45

Writing a file line by line using separate functions. C++?

I want to get the file:
fileConfiguration.cfg
Station name,1,2001
14,6A,8D
1,current f A,,,A,1.290489E-01,0,0,-32767,32767,3000.00000000,1.00000000,P
2,current B,,,A,5.139708E-02,0,0,-32767,32767,3000.00000000,1.00000000,P
Help me get this right.
1. How to describe the implementation of void writesecondline (std::ostream &file, InfAnalogChanel const &iac);
function.h

class Station // 1-я строка
{
public:
   std::string station_name;
   std::string rec_dew;
   std::string year;
};
    void writefirstline(std::string station_name,std::string rec_dew,std::string year); //функция записи 1-й строки

class InfaboutChanell // 2-я строка
{
    public:
    int chanellcount;
    int analogChanell;
    int discretChanell;
};
 void writecountCh(int chanellcount,int analogChanell, int discretChanell); //функция записи 2-й строки


class InfAnalogChane  l// 3-я строка
{
public:
   int id;
   std::string chanell_id;
   std::string ph;
   std::string ccmb;
   std::string UU;
   double a;
   double b;
   double skew;
   double min;
   double max;
   double Primery;
   double Secondary;
   std::string SP;
};
void writesecondline (std::ostream &file, InfAnalogChanel const &iac);  //функция записи 3-й строки

function1.cpp
void writefirstline(std::string station_name,std::string rec_dew,std::string year){
        ofstream file("fileConfiguration.cfg");
        file<<station_name<<","<<rec_dew<<","<<year<<"\n";
        }

        void writecountCh(int chanellcount,int analogChanell, int discretChanell){
            ofstream file("fileConfiguration.cfg");
            file<<chanellcount<<","<<analogChanell<<"A"<<","<<discretChanell<<"D"<<"\n";
        }

        void writesecondline(std::ostream &file, InfAnalogChanel const &iac){
            ofstream efile("fileConfiguration.cfg");

        }

main.cpp
writefirstline("Station name","1","2001");
  writecountCh(14, 6, 8);

 

  InfAnalogChanel a = {1,"ток ф А",,,"A",1.290489E-01,0,0,-32767,32767,3000.00000000,1.00000000,"P"};
  InfAnalogChanel b = {2,"ток В",,,"A",5.139708E-02,0,0,-32767,32767,3000.00000000,1.00000000,"P"};

  ofstream efile("fileConfiguration.cfg");
  writesecondline(efile, a);
  writesecondline(efile, b);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question