Hello everyone,

I have a question regarding advanced file manipulation. I am trying to make a function that will take in a number which will be the number of a record and basically take that record out and display its contents and let the user edit it.
Here is the code:

#include <iostream>
#include <fstream>
using namespace std;

int main ()
  const int SIZES = 100;
  struct Speech
         char beginning[SIZES];
         char str1[SIZES];
         char str2[SIZES];
         char str3[SIZES];
  Speech mybot;
  fstream outputFile;
  outputFile.open("umai6r.txt", ios::in | ios::out | ios::app);
  cout << "which one? ";
  long num;
  cin >> num;
  outputFile.seekg(num * sizeof(mybot), ios::beg);
  outputFile.read(reinterpret_cast<char *>(&mybot), sizeof(mybot));
  cout << "\n";
  cout << mybot.beginning;
  cout << "\n";
  cout << mybot.str1;
  cout << "\n";
  cout << mybot.str2;
  cout << "\n";
  cout << mybot.str3;
  cout << "\n";

  cin >> mybot.beginning;
  cout << "123123123";
  cin >> mybot.str1;
  cout << "123123";
  cin >> mybot.str2;
  cout << "123123";
  cin >> mybot.str3;
  cout << "123123123";

  outputFile.seekp(num * sizeof(mybot), ios::beg);
  outputFile.write(reinterpret_cast<char *>(&mybot), sizeof(mybot));
  return 0;

I know its not complete. Nor is it in the format of a function. I will turn it into function later. Right now I just want to make sure it works. The problem with this is that it doesn't even create a file with the name I gave. Any help would be appreciated.

8 Years
Discussion Span
Last Post by SCarlisle

never mind everyone, I got it. Thanks for the help anyways.


I had the same problem so I'm anxious to see what the answer is. I could not get it to create a file either.


Edited by SCarlisle: n/a

Votes + Comments
I think you're just a link spammer posting any old crap on any old thread just for the hell of it
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.