Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-27-2007, 07:01 PM
NoName NoName is offline
Newbie
 
Join Date: Aug 2007
Posts: 6
Rep Power: 0
NoName is on a distinguished road
Question Works when i have an int

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;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-28-2007, 12:25 AM
NoName NoName is offline
Newbie
 
Join Date: Aug 2007
Posts: 6
Rep Power: 0
NoName is on a distinguished road
Default

well i found the problem... my telephone array was to small lol but why that would be fixed with the int i have no idea
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
1 million $$ on Adsense!!!! Lop Affiliate Marketplace 35 11-11-2007 12:51 PM
Need help on matrix. sania21 Java Help 15 06-28-2007 04:29 AM
What works best NeedHelp Marketing 11 07-21-2006 11:51 AM


All times are GMT -5. The time now is 04:48 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads