473,473 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Anyone have a description for this problem?

8 New Member
My program uses the following code
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. void in_mas(FILE *f,int *a,int *len)
  4.     int ch,c,fl=0,l=10;long see=0;
  5.     long i=0;
  6.   while(i<=l||(!feof(f)))
  7.   {
  8.  
  9.       fscanf(f,"%d",&c);
  10.        (*len)++;
  11.         a[i]=c;
  12.         i++;
  13.   }  
  14.      if(!feof(f)) printf("fdfd");
  15.       if (!feof(f))
  16.       {
  17.           while(!feof(f))
  18.               {
  19.                  fscanf(f,"%d",&ch);
  20.                  (*len)++;
  21.               }
  22.               a=(int*) realloc(a,(*len)*sizeof(int));
  23.               printf("%d\n ",(*len));
  24.               rewind(f);l=0;
  25.               printf("%d ",i);
  26.               while(!feof(f))
  27.               {
  28.                   fscanf(f,"%d",&c);
  29.                   if(l>i)
  30.                       a[l]=c;
  31.                   l++;
  32.               }
  33.  
  34.       }
  35. }
  36.  
  37.  
  38.   void out_mas(int *a,int *len)
  39.   {
  40.       int i=0;
  41.       for( i;i<*len;i++)
  42.       {printf("%d ",a[i]);}
  43.   }
  44.   int main()
  45.   {
  46.       int *a;
  47.       int *len;
  48.       int p;
  49.       len=&p;
  50.       *len=0;
  51.       FILE *fpr;
  52.       fpr=fopen("t.txt","r");
  53.  
  54.       if((a=(int *)malloc(10*sizeof(int)))==NULL)
  55.              printf("Error\n");
  56.       else
  57.       {
  58.       in_mas(fpr,a,len);
  59.       out_mas(a,len);
  60.       free(a);}
  61.       return 0;
  62.   }
  63.  
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?
Mar 23 '11 #1
3 1322
mac11
256 Contributor
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.
Mar 23 '11 #2
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.
Mar 25 '11 #3
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.
Mar 25 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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...
11
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 {...
0
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...
3
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...
1
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...
2
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...
3
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...
7
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...
4
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...
2
crabpot8
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...
0
marktang
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.