Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @File :
- *
- * @Author : A. B. Dragut
- *
- * @Synopsis : modelmain
- **/
- #include <string>
- #include <exception>
- #include <iostream>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h> // getdtablesize()
- #include <sys/time.h> // fd_set
- #include "nsSysteme.h"
- #include "CExc.h"
- using namespace nsSysteme;
- using namespace std;
- int main(int argc, char * argv [])
- {
- try {
- int File = Open(argv[1],O_RDONLY);
- //ZONE 1
- char C;
- Read(File,&C,sizeof(char));
- cout << "Zone 1 : " << C << endl;
- //ZONE 2
- int I;
- Read(File,&I,sizeof(int));
- cout << "Zone 2 : " << I << endl;
- //ZONE 3
- /* string S;
- Read (File, &S, I);
- cout << "Zone 3 : " << S; */
- char S [I];
- S[I] = '\0';
- Read(File, &S, I);
- cout << "Zone 3 : " << S << endl;
- //ZONE 4
- char buf[I];
- int NbBytRest;
- cout << "Zone 4 : ";
- while ( ( NbBytRest = Read (File, &buf, 1024 )) > 0 )
- {
- buf[NbBytRest]= '\0';
- cout << buf;
- }
- cout << endl;
- ///code
- return 0;
- }
- catch (const CExc & Exc) {
- cerr <<Exc<< endl;
- return errno;
- }
- catch (const exception & Exc) {
- cerr << "Exception : " << Exc.what () << endl;
- return 1;
- }
- catch (...) {
- cerr << "Exception inconnue recue dans la fonction main()"
- << endl;
- return 1;
- }
- } // main()
Add Comment
Please, Sign In to add comment