help needed with writing to a file

so im trying to read in the name of a vendor into an array of structures. and write the name into a file. doing this gets me an error i haven't seen before and searching for it online has proven very unfruitful. any help would be awesome!
heres my code so far

the .h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <cstring>
#include <cctype>
#include <fstream>


using namespace std;


 struct booth
{
   char *vendorName;
   char *category;
   char *description;
   char *email;
   char temp[100];
};
 struct guests
{
   char *guestName;
   char *accomplishemnt;
};
 struct node
{
   booth data;
   node *next;
};


and my main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "main.h"
using namespace std;

void GetVendor (booth *vendorName);
void GetCategory (booth *category);

int main()
{
  ifstream fin;
  ofstream fout;
  char again('Y');
  booth *vendorName = NULL;
  booth *category = NULL;

  while (again == 'Y' || again == 'y')
 {
    GetVendor ( vendorName );
    GetCategory ( category );

    cout << "Would you like to run again?(y/n) " << endl;
    cin >> again;
 }
    return 0;
}

 void GetVendor (booth *vendorName)
{
  ofstream myfile;
  booth temp[100];
  myfile.open("booth.txt", ios::app);

  if (myfile)
  {
   cout << "Please enter Vendor name: " << endl;
   cin.get (temp, 100, '\n');
   cin.ignore(100, '\n');

   *vendorName = new booth[strlen(temp) + 1];
   strcpy( *vendorName, temp);

    myfile << *vendorName;
    myfile.close();
  }

  delete [] vendorName;
}
void GetCategory ( booth  *category )
{
  ifstream fin;
  booth temp[100];
  file.open ("booth.txt", ios::app);
 if (fin)
 (
   cout << "please enter the catagory of your booth: " << endl;
   cin.get (temp, 100, '\n');
   cin.ignore(100, '\n');

   category = new booth[strlen(temp) + 1];
   strcpy ( category, temp );
}

Is there a reason you're not using std::string for strings (instead of char*)?
no, im fairly new to programming and didnt know that i should
closed account (Dy7SLyTq)
whats your error? and why do u have an i/o file stream in main if you dont use it?
Yea, need error to give us clues where it's happening.
my error was with my struct and not creating the struct variable. i solved it thankfully
Topic archived. No new replies allowed.