daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *
  3.  * @File :
  4.  *
  5.  * @Author : A. B. Dragut
  6.  *
  7.  * @Synopsis : modelmain
  8.  **/
  9.  
  10. #include <string>
  11. #include <exception>
  12. #include <iostream>
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <fcntl.h>
  16.  
  17. #include <unistd.h>     // getdtablesize()
  18. #include <sys/time.h>   // fd_set
  19.  
  20. #include "nsSysteme.h"
  21. #include "CExc.h"
  22.  
  23. using namespace nsSysteme;
  24. using namespace std;
  25.  
  26. int main(int argc, char * argv [])
  27. {
  28.   try {
  29.  
  30.     int File = Open(argv[1],O_RDONLY);
  31.    
  32.  
  33.     //ZONE 1
  34.      char C;
  35.      Read(File,&C,sizeof(char));
  36.      cout << "Zone 1 : " << C << endl;
  37.  
  38.     //ZONE 2
  39.  
  40.     int I;
  41.     Read(File,&I,sizeof(int));
  42.     cout << "Zone 2 : " << I << endl;
  43.  
  44.     //ZONE 3
  45. /*  string S;
  46.     Read (File, &S, I);
  47.     cout << "Zone 3 : " << S; */
  48.  
  49.     char S [I];
  50.     S[I] = '\0';
  51.     Read(File, &S, I);
  52.     cout << "Zone 3 : " << S << endl;
  53.  
  54.     //ZONE 4
  55.  
  56.     char buf[I];
  57.     int NbBytRest;
  58.  
  59.     cout << "Zone 4 : ";
  60.    
  61.     while ( ( NbBytRest = Read (File, &buf, 1024 )) > 0 )
  62.     {
  63.         buf[NbBytRest]= '\0';
  64.         cout << buf;
  65.     }
  66.  
  67.     cout << endl;
  68.  
  69. ///code
  70.     return 0;
  71.   }
  72.   catch (const CExc & Exc) {
  73.         cerr <<Exc<< endl;
  74.         return errno;
  75.   }
  76.   catch (const exception & Exc) {
  77.         cerr << "Exception : " << Exc.what () << endl;
  78.         return 1;
  79.   }
  80.   catch (...) {
  81.         cerr << "Exception inconnue recue dans la fonction main()"
  82.              << endl;
  83.         return 1;
  84.   }
  85.  
  86.  
  87. }  //  main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top