I have a struct where i have 1 int and 7 char arrays and every thing was working
Code:
struct record {
int id;
char firstName[30];
char lastName[30];
char address[30];
char city[30];
char state[2];
char zip[6];
char telephone[10];
};
but i took out the int because i dont really need it but now i get an error when i run my program
"Run-Time Check Failure #2 - Stack around the variable 'test' was corrupted."
so i added the int back in just to see if some how it would work again and well it did so why the hell is it doing this taking an int out should not do this
here is the rest of my test program
Code:
#include <iostream>
#include <fstream>
using namespace::std;
struct record {
char firstName[30];
char lastName[30];
char address[30];
char city[30];
char state[2];
char zip[6];
char telephone[10];
};
ostream & operator<<(ostream & OUT,record & r)
{
OUT << r.firstName << ends
<< r.lastName << ends
<< r.address << ends
<< r.city << ends
<< r.state << ends
<< r.zip << ends
<< r.telephone << endl;
return OUT;
}
int main()
{
record test;
strcpy(test.firstName,"Dan");
strcpy(test.lastName,"Brown");
strcpy(test.address,"212 W 133 rd");
strcpy(test.city,"Overland Park");
strcpy(test.state,"KS");
strcpy(test.zip,"66061");
strcpy(test.telephone,"8166226187");
ofstream f("c:\\test.txt",ios::binary);
if(f.is_open())
f << test;
else
cout << "Crap" << endl;
f.close();
return 0;
}