Subj : Re: directly inputting numbers To : borland.public.cpp.borlandcpp From : waking@idirect.com (Wayne A. King) Date : Fri Jul 18 2003 07:51 pm On 17 Jul 2003 09:42:06 -0700, "Michael Fruchter" wrote: >Am I correct to conclude that >there is no way to directly read in the text as a number? >(i.e., by telling it to read a certain amount of places) You can use fscanf() and the width specifier to read a specific number of characters for each number. >is it possible to read the file directly >into the data array (without first reading the file into the buffer string)? Yes. See if this example comes close to what you want. (N.B. - Error checking kept to a minimum. Beef it up!) Create a text file named "nums.txt" with lines such as: 12345678111122223333444455556666777788889999 00010002000300040005000600070008 #include #include int main() { int i, ret; long numary[20] = {0}; FILE *fp = fopen("nums.txt", "rt"); if(!fp) { fprintf(stderr, "Can't open input file!\n"); return EXIT_FAILURE; } for(i=0; i