IHYPRESS.NET > C PROGRAMMING
HOME | ASP | C | HTML/CSS | JAVASCRIPT | MATLAB | PERL | PHP | PYTHON | RUBY
C > 07. Arrays I (1D) [PROGRAM #04]
CODERESULT
<
/* Problem: This program fills an array from a file */
#include <stdio.h> #define SIZE 10 /* size of the array */ int main (void) { int numbers[10], i; FILE *input; input = fopen("numbers.txt", "r"); /* reading file - filling array */ for (i=0; i<SIZE; ++i) fscanf(input, "%d", &numbers[i]); /* printing the content of array */ printf("The numbers read are: "); for (i=0; i<SIZE; ++i) printf("%4d", numbers[i]); printf ("\n"); fclose (input); return (0); }
Legend: preprocessor directives | variable declarations main function | helper functions | user-defined structures comments
The numbers read are:   43  56  23  87 123  13  77  41   9  10
>
COPYRIGHT © 2019 IHYPRESS.NET. A DIVISION OF IHY PRESS, KIRKLAND, WA 98083 USA. ALL RIGHTS RESERVED.
Deals of the Week: New deals every week, online only!
SHARE