src/linux_parser.cpp
// TODO: Read and return the total number of processes
Read and return the total number of processes
Read and return the total number of processes
int LinuxParser::TotalProcesses() { 
  int Total_process ;
  string line, T_P;
  std::ifstream stream(kProcDirectory + kStatFilename);
  if (stream.is_open()){
    while (std::getline(stream, line)){
      std::replace(line.begin(), line.end(), ':',' ');
      std::istringstream linestream(line);
      while (linestream>>line>>T_P){
        if (line == "processes"){Total_process = std::stoi(T_P);}
      }
    }
  }
  return Total_process;}
int LinuxParser :: TotalProcesses ( ) { int Total_process ; string line , T_P ; std :: ifstream stream ( kProcDirectory + kStatFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream linestream ( line ) ; while ( linestream >> line >> T_P ) { if ( line == " " ) { Total_process = std :: stoi ( T_P ) ; } } } } return Total_process ; }
TODO: Read and return the total number of processes
TODO : Read and return the total number of processes
// std::cout << T_P <<"  " << Total_process<< "\n";