By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,372 Members | 1,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,372 IT Pros & Developers. It's quick & easy.

heey can someone help me with these

P: 2
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #define N 16
  3. #define FILENAME "exp1.txt"
  4.  
  5.  
  6.  
  7. int main(void)
  8. {
  9.     int k,count=0;
  10.  
  11.     double y[N];
  12.  
  13.     FILE *exp;
  14.  
  15.     exp=fopen(FILENAME,"r");
  16.  
  17.     if (exp == NULL)
  18.  
  19.         printf("error opening input file.\n");
  20.  
  21.     else
  22.     {
  23.  
  24.         for(k=0;k<=N-1;k++)
  25.  
  26.         {
  27.             fscanf(exp,"%lf",&y[k]);
  28.  
  29.             count++;
  30.  
  31.         }
  32.  
  33.         printf("the number is : %i\n",count);
  34.  
  35.         fclose(exp);
  36.     }
  37.  
  38.     return 0;
  39.  
  40. }


im getting runtime error
May 23 '07 #1
Share this Question
Share on Google+
2 Replies


Savage
Expert 100+
P: 1,764
#include<stdio.h>
#define N 16
#define FILENAME "exp1.txt"



Expand|Select|Wrap|Line Numbers
  1. int main(void)
  2. {
  3.     int k,count=0;
  4.  
  5.     double y[N];
  6.  
  7.     FILE *exp;
  8.  
  9.     exp=fopen(FILENAME,"r");
  10.  
  11.     if (exp == NULL)
  12.  
  13.         printf("error opening input file.\n");
  14.  
  15.     else
  16.     {
  17.  
  18.         for(k=0;k<=N-1;k++)
  19.  
  20.         {
  21.             fscanf(exp,"%lf",&y[k]);
  22.  
  23.             count++;
  24.  
  25.         }
  26.  
  27.         printf("the number is : %i\n",count);
  28.  
  29.         fclose(exp);
  30.     }
  31.  
  32.     return 0;
  33.  
  34. }

im getting runtime error
What type of runtime error?

(I runed trough ur code and it was runtime error free)

And please use code tags when posting ur code.

Savage
May 23 '07 #2

sicarie
Expert Mod 2.5K+
P: 4,677
Please take a look at the Posting Guidelines, specifically the parts about asking specific questions, including errors you are getting, using good titles, and using code tags. Thanks!
May 23 '07 #3

Post your reply

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