summaryrefslogtreecommitdiff
path: root/userspace/cpp/testcpp.cpp
blob: 53e3a3b556c680cd71520f2d06ed18d5d8374ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <algorithm>
#include <vector>
#include <cstdio>
#include <iostream>

void prep();
void myinit();

int main()
{
    prep();
    myinit();

 int myints[] = {32,71,12,45,26,80,53,33};
  std::vector<int> myvector (myints, myints+8);               // 32 71 12 45 26 80 53 33

  // using default comparison (operator <):
  std::sort (myvector.begin(), myvector.begin()+4);           //(12 32 45 71)26 80 53 33

  for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
    printf("%i\n",*it);  
    printf("hello\n");

//    printf("reent struct size: %d bytes\n",sizeof(struct _reent));
  //  printf("reent pointer : 0x%08x\n",_impure_ptr);
    //printf("reent pointer : 0x%08x\n",_impure_ptr);
    std::cout << "bye bye" << std::endl;
    printf("hello\n");
}

// constructing vectors
/*
#include <iostream>
#include <vector>
#include <cstring>
#include <reent.h>

//#undef _REENT_GLOBAL_STDIO_STREAMS 

int main()
{
    std::cout << "hi" << std::endl;
  _REENT_INIT_PTR(_impure_ptr);


    

      // constructors used in the same order as described above:
  std::vector<int> first;                                // empty vector of ints
  std::vector<int> second (4,100);                       // four ints with value 100
  std::vector<int> third (second.begin(),second.end());  // iterating through second
  std::vector<int> fourth (third);                       // a copy of third

  // the iterator constructor can also be used to construct from arrays:
  int myints[] = {16,2,77,29};
  std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );

  std::cout << "The contents of fifth are:";
  for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '\n';



    return 0;
}
*/