Data File Handling Error, Please Help!

I have this code for a computer project... (store management) but the character strings are not copied on text file.. pls help
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
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
class Store
{
public:
char *item_name[5];
store()
{
item_name[1]="Monitor";
item_name[2]="Motherboard";
item_name[3]="Speaker";
item_name[4]="Laptops";
item_name[5]="Printer";
}
};
void main()
{
Store c;
fstream f;
f.open("STORE.TXT",ios::out);
for(int i=0;i<5;i++)
{
f<<c.item_name[i];
}
cout<<"\nSuccess";
f.close();
}

now when i run the program, it gives a error :::
ERROR
address 0x0

How can i write these strings to the text file?
Before you use a pointer array, you have to allocate memory to it, perhaps the "string" library would work better for your purposes
The problem is on lines 10-14.

Remember that in C++ arrays start at zero, not 1. So a five-element array has indices 0, 1, 2, 3, and 4.

Hope this helps.
Topic archived. No new replies allowed.