ofstream question

This should create a file containing '1'. However, it does not create anything at all. What is going on?
1
2
3
4
5
      int a = 1;
      cout << a << endl;
      ofstream ofs(argv[3],ios_base::out | ios_base::trunc);
      ofs << a; 
      ofs.close();


Thanks!
Does argv[3] actually exist? Are you checking? Try chaninging ios_base::out | ios_base::trunc to ios::out | ios::trunc

Post some more code please.
Last edited on
. yeah.. that was the error. I thought the vector was indexed from 1 to argc, but instead it was indexed from 0 to argc-1.
Thanks!
Topic archived. No new replies allowed.