Здравствуйте, PunkRat, Вы писали:
PR>Помогите пожалуйста решить пустяковую проблемку. Есть файл текстовый с цифрами там записанными, не разделёнными пробелами. Нужно считать значения этих цифр в массив — каждая цифра в отдельный элемент массива целых. Подскажите пожалуйста какой нибудь способ, очень нужно, желательно чтоб в DOS тоже работало.
int fgetc( FILE *stream );
Пример из MSDN:
/* FGETC.C: This program uses getc to read the first
* 80 input characters (or until the end of input)
* and place them into a string named buffer.
*/
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
FILE *stream;
char buffer[81];
int i, ch;
/* Open file to read line from: */
if( (stream = fopen( "fgetc.c", "r" )) == NULL )
exit( 0 );
/* Read in first 80 characters and place them in "buffer": */
ch = fgetc( stream );
for( i=0; (i < 80 ) && ( feof( stream ) == 0 ); i++ )
{
buffer[i] = (char)ch;
ch = fgetc( stream );
}
/* Add null to end string */
buffer[i] = '\0';
printf( "%s\n", buffer );
fclose( stream );
}