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));
  
  
  outputFile.close();
  system("pause");
  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.

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.

Ed

commented: I think you're just a link spammer posting any old crap on any old thread just for the hell of it -4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.