[ create a new paste ] login | about

Link: http://codepad.org/Cvk2dUaA    [ raw code | output | fork ]

C++, pasted on Nov 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main() {

  vector<char> v;

  // write
  float f = 42.42;
  v.insert(v.end(), reinterpret_cast<char*>(&f), reinterpret_cast<char*>(&f) + sizeof f);

  // read
  float r;
  copy(&v[0], &v[0] + sizeof r, reinterpret_cast<char*>(&r));

  cout << f << '\n' << r << '\n';
}


Output:
1
2
42.42
42.42


Create a new paste based on this one


Comments: