hello I have the following program in which i am tring to copy one strct array to another so that i can sort the second struct array without messing up the original one so i do the copy but when i run the program it give the following error :
Unhandled exception at 0x0f5bbef0 (msvcr100d.dll) in lab8A.exe: 0xC0000005: Access violation reading location 0xcccccccc.
i have no idea what im doing wrong if some one can help me out i would very much appreciate it

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

struct survey
    string code;
    double income;
    int members;
ifstream infile;
ofstream outfile;
int main()
    int choice;
    survey w[16];
    survey dw[16];
    infile.open ("E:\\lab8adatafile.txt");
    if (!infile)

        cout<<"Cannot open file, terminating program"<<endl;
        system ("pause");
        return 0;

        for(int i=0; i<16;i++)
        dw[16]=w[16]; // here is where i copy the struct w to struct dw 
    cout<<"house code "<<"income "<<"Members " <<endl;
    for (int l=0;l<16;l++)
        cout<<w[l].code<<" "<<w[l].income<<" "<<w[l].members<<" "<<endl;

        cout<<"1. Print all of the input data with appropriate column headings. "<<endl;
        cout<<"2. Calculate the average household income and list the identification  "<<endl; 
        cout<<"   codes and income of each household whose income is greater than the average. "; 
        cout<<"3. Determine the percentage of households having an income below the poverty "<<endl;
        cout<<"4. Print all of the input data sorted by household income "<<endl;
        cout<<"5. Calculate and print the median household income "<<endl;
        cout<<"6. Exit";
        cout<<"\n\nEnter your choice 1-6 :";


    return 0;
This article has been dead for over six months. Start a new discussion instead.