My program uses the following code -
#include <stdio.h>
-
#include <stdlib.h>
-
void in_mas(FILE *f,int *a,int *len)
-
{
-
int ch,c,fl=0,l=10;long see=0;
-
long i=0;
-
while(i<=l||(!feof(f)))
-
{
-
-
fscanf(f,"%d",&c);
-
(*len)++;
-
a[i]=c;
-
i++;
-
}
-
if(!feof(f)) printf("fdfd");
-
if (!feof(f))
-
{
-
while(!feof(f))
-
{
-
fscanf(f,"%d",&ch);
-
(*len)++;
-
}
-
a=(int*) realloc(a,(*len)*sizeof(int));
-
printf("%d\n ",(*len));
-
rewind(f);l=0;
-
printf("%d ",i);
-
while(!feof(f))
-
{
-
fscanf(f,"%d",&c);
-
if(l>i)
-
a[l]=c;
-
l++;
-
}
-
-
}
-
}
-
-
-
void out_mas(int *a,int *len)
-
{
-
int i=0;
-
for( i;i<*len;i++)
-
{printf("%d ",a[i]);}
-
}
-
int main()
-
{
-
int *a;
-
int *len;
-
int p;
-
len=&p;
-
*len=0;
-
FILE *fpr;
-
fpr=fopen("t.txt","r");
-
-
if((a=(int *)malloc(10*sizeof(int)))==NULL)
-
printf("Error\n");
-
else
-
{
-
in_mas(fpr,a,len);
-
out_mas(a,len);
-
free(a);}
-
return 0;
-
}
-
It works just fine, but after i run it i get the following error message:
Debug error!
DAMAGE:after Normal block(#45) at 0x001C1D20
Can anyone please tell me what's the reason for this error?
3 1322
Probably related to the first while in in_mas. That one looks fishy to me. Maybe go through that loop in your head and draw out your array and it's contents on paper as you go.
donbock 2,426
Recognized Expert Top Contributor
Can you find the statements that printed out that error message? There ought to be a conditional test nearby that would help to explain what went wrong.
Banfa 9,065
Recognized Expert Moderator Expert
I believe that message is produced by the Debug C runtime library because it has detected corruption in a block of allocated memory either as it was freed or as the program exited.
Since you only allocate 1 block of memory, the cryptically named a the problem must be with what you are doing with that.
A agree with mac11, you loop lines 7 - 14 needs careful examination with reference to the size of a .
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Clifford W. Racz |
last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML)
into xHTML? I have been trying to get the nested table code for my XSLT
to work for a while now, with no way to get the...
|
by: Aing |
last post by:
Anyone knows what can be cause of this problem?
////////////////////////////////////////////////////////////
typedef struct _date_struct {
int date,month,year;
}date_struct;
Class Date {...
|
by: CroDude |
last post by:
Hi all!
I've just realized that Panel class doesn't provide KeyDown/KeyUp events.
Does anyone know how to remedy this problem. I really need for the panel to
catch keyboard events.
Thanks in...
|
by: Anthony Nystrom |
last post by:
This is really getting old and frustrating... For now reason that I can
determine my copy and paste functionality is gone, as well as bring to front
bring to back etc... Only happens in the...
|
by: MPutt |
last post by:
I apologize if I am posting this to the wrong area, but I am stuck.
Here is my problem.
I am running a .NET 2003 Windows service against Oracle 9i. This
service is attempting to run a stored...
| |
by: Sean Hammond |
last post by:
Anyone understand this?
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
.... """Send 'input' (string) to the...
|
by: lraoux |
last post by:
Hi everyone, I'm new here. I study Comp Sci at UCLA.
So anyways, I am using Microsoft Visual Studio 2005 to code this project. After I built the project and got no compile time error, I clicked...
|
by: Rob |
last post by:
I've trying to import a CSV file exported from another application but it
uses some encoding scheme I've not seen before:
19/02/2007,106478,Bob Elder,Sinking Ship,Macclesfield,Cheshire,8,"Mike\'s...
|
by: Wayne |
last post by:
I am putting together an A2007 database using Windows Vista. I
noticed that when I roll my mouse cursor onto and off a command button
the command button gives a flicker. To ensure that the...
|
by: crabpot8 |
last post by:
Anyone see the problem with this? Basically I am trying to get this to work, so that I can modify it to say something similar to select *, ABS(DATEDIFF ... ) from ...
so that I can get 1) all the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |