File pointer not moving to the end of the file

I'm trying to move the File Pointer to the end of the file (check.txt) at line-13. But doesn't matter how many times I run the program out put always comes as

O/P:
Pos=0
Pos=0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <fstream>
#include <ostream>
using namespace std;

int main () {
  streampos size;
  char * memblock;
  ofstream file ("check.txt", ios::out);
  if (file.is_open())
  {
      cout<<"\n Pos="<<file.tellp();
      file.seekp(0, ios::end);\\Line-13
      cout<<"\n Pos="<<file.tellp();
      memblock = new char [4];
      memblock = "Cool";
      file.write(memblock, 4);
      file.close();
      delete[] memblock;

  } else {cout << "Unable to open file";}
  return 0;
}

Last edited on
Topic archived. No new replies allowed.