[oi-dev] System programming on Solaris
ilya at arhipkin.com
ilya at arhipkin.com
Thu Jul 30 11:16:09 UTC 2015
Hello all developers!!!
Found on the Internet a simple program explain how to write a program,
and device programs.
First you have to set a variable that is displayed if the tether
main.cpp write in C ++
So we call file hello.cpp
#include <iostream>
#include "functions.h"
using namespace std;
void print_hello () {
cout << "Hello World!";
}
Then write the header file connectivity oistream
// - * - C ++ - * -
/ *
* File: iostream.
* Author: Ilya Arhipkin
*
* Created on July 16, 2015, 8:20
* /
/ *
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty
expressed
* Or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby
granted
* Without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is
granted,
* Provided the above notices are retained, and a notice that the code
was
* Modified is included with the above copyright notice.
*
* /
#ifndef _STLP_IOSTREAM_H
#define _STLP_IOSTREAM_H
#ifndef _STLP_OUTERMOST_HEADER_ID
# Define _STLP_OUTERMOST_HEADER_ID 0x2035
# Include <stl / _prolog.h>
#endif
#include <iostream>
// Those should be included all separately, as they do contain using
declarations
#include <streambuf.h>
#include <ostream.h>
#include <istream.h>
#ifndef _STLP_HAS_NO_NAMESPACES
# Ifdef _STLP_BROKEN_USING_DIRECTIVE
_STLP_USING_NAMESPACE (Stlport)
# Else
using _STLP_STD :: cin;
using _STLP_STD :: cout;
using _STLP_STD :: clog;
using _STLP_STD :: cerr;
using _STLP_STD :: iostream;
# Ifndef _STLP_NO_WCHAR_T
using _STLP_STD :: wcin;
using _STLP_STD :: wcout;
using _STLP_STD :: wclog;
using _STLP_STD :: wcerr;
# Endif
# Endif
#endif / * _STLP_HAS_NO_NAMESPACES * /
// Obsolete classes for old-style backwards compatibility
class istream_withassign: public istream {
public:
istream_withassign (): istream ((streambuf *) 0) {}
~ Istream_withassign () {}
istream_withassign & operator = (istream & __s) {
ios :: init (__ s.rdbuf ());
return * this;
}
istream_withassign & operator = (streambuf * __s) {
ios :: init (__ s);
return * this;
}
};
class ostream_withassign: public ostream {
public:
ostream_withassign (): ostream ((streambuf *) 0) {}
~ Ostream_withassign () {}
ostream_withassign & operator = (ostream & __s) {
ios :: init (__ s.rdbuf ());
return * this;
}
ostream_withassign & operator = (streambuf * __s) {
ios :: init (__ s);
return * this;
}
};
class iostream_withassign: public iostream {
public:
iostream_withassign (): iostream ((streambuf *) 0) {}
~ Iostream_withassign () {}
iostream_withassign & operator = (ios & __i) {
ios :: init (__ i.rdbuf ());
return * this;
}
iostream_withassign & operator = (streambuf * __s) {
ios :: init (__ s);
return * this;
}
};
#if (_STLP_OUTERMOST_HEADER_ID == 0x2035)
# Include <_epilog.h>
# Undef _STLP_OUTERMOST_HEADER_ID
#endif
#endif / * _STLP_IOSTREAM_H * /
// Local Variables:
// Mode: C ++
// End:
function.h
/ *
* File: functions.h
* Author: Ilya Arhipkin
*
* Created on July 16, 2015 8:17
* /
void print_hello ();
int factorial (int n);
This header file describes variable print_hello
and variable factorial
Writing software factorial
factorial.cpp
#include "functions.h"
int factorial (int n) {
if (n! = 1) {
return (n * factorial (n-1));
}
else return 1;
}
Finally, the file main.cpp
#include <iostream>
#include "functions.h"
using namespace std;
int main () {
print_hello ();
cout << endl;
cout << "The factorial of 5 is" << factorial (5) << endl;
return 0;
}
--
http://www.arhipkin.com
More information about the oi-dev
mailing list