468,504 Members | 1,916 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,504 developers. It's quick & easy.

C Run-Time Error R6002

RADAR
21
hi,
the error code was taken from msdn and it occured in my code as follows;
i am reading buffer from the file :

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define SIZE 10
  4. #define DSIZE 5
  5. #define DEPTH 150
  6.  
  7. //LL structure
  8. typedef struct node* NODE_PTR;
  9. typedef struct node POOL;
  10. struct node{
  11.  
  12.     int dept;
  13.     int std_num;
  14.     char name[SIZE];
  15.     char lastname[SIZE];
  16.     double cgpa;
  17.     NODE_PTR link;
  18.  
  19. };
  20.  
  21. //--main method
  22. int main(void)
  23. {
  24.     NODE_PTR dept[DSIZE];//--departments will be sent to this header...
  25.     NODE_PTR temp;//--used for allocation of new nodes.
  26.     POOL swim[DEPTH];//--send students read from file to pool
  27.     int i = 0;//--counter for struct type swim.
  28.  
  29.     //--reading from the file Faculty.txt:
  30.     FILE* fp;
  31.     char* file_name = "C:\\Faculty\\Faculty.txt";
  32.  
  33.  
  34.     //--open the file and Read it...
  35.     fp = fopen(file_name,"r+");
  36.  
  37.     //--if there are problems while reading from the file:
  38.     if(fp == NULL)
  39.     {
  40.         printf("There are problems with file reading operations...\n"
  41.             "The program will exit immediately...\n");
  42.         exit(1);
  43.     }
  44.  
  45.     //--no problems with reading from file , scan the components to the LL structure:
  46.     while(!feof(fp) && i < DEPTH)
  47.     {
  48.         //--node->ordered to be read:dept(int),
  49.         //--------std_num(int),name(charARR),lastname(charARR),cgpa(double)
  50.         fscanf(fp,"%d %d %s %s %lf",
  51.             &swim[i].dept,
  52.             &swim[i].std_num,
  53.             swim[i].name,
  54.             swim[i].lastname,
  55.             &swim[i].cgpa
  56.             );
  57.         i++;
  58.     }//--end of scanning the file
  59.     return 0;
  60. }
  61.  
that's the code i have the run-time errors , i wonder you have some solutions,
respects;
RADAR
Dec 13 '07 #1
1 3689
RADAR
21
for the clarification of the faculty.txt file , it includes
eg.
[dept. code] [std.number] [std.name] [std.lastname] [cgpa];
25 190527 Brad Pitt 1.2
Dec 13 '07 #2

Post your reply

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

Similar topics

3 posts views Thread by leroybt.rm | last post: by
13 posts views Thread by Bob Day | last post: by
19 posts views Thread by Bryan | last post: by
9 posts views Thread by Brett Wesoloski | last post: by
8 posts views Thread by David Thielen | last post: by
3 posts views Thread by traceable1 | last post: by
7 posts views Thread by mxdevit | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.