File indexing completed on 2024-06-16 04:24:44

0001 /*
0002    Copyright 2009 Niko Sams <niko.sams@gmail.com>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2 as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #include <iostream>
0020 
0021 #ifndef _MSC_VER
0022 #include <unistd.h>
0023 #else
0024 #include <Windows.h>
0025 #define sleep Sleep
0026 #endif
0027 
0028 void foo() {
0029     static int i=0;
0030     ++i;
0031     std::cout << i << std::endl;
0032     sleep(2);
0033 }
0034 
0035 int main() {
0036     std::cout << "Hello, world!" << std::endl;
0037     for (int i=0; i<3; i++) {
0038         foo();
0039     }
0040 
0041     return 0;
0042 }