IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
COne Dimensional Arrays : Filling an Array from a File
<07.04>
/* 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); }
Hergestellt in Deutschland / Made in Germany
The numbers read are: 43 56 23 87 123 13 77 41 9 10
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland