При работе с файлом появляется ошибка debug assertion failed - C (СИ)
Формулировка задачи:
При работе с файлом вылезает ошибка debug assertion failed.Как устранить ошибку? Помогите, пожалуйста.
#include <stdio.h>
#include <iostream>
#include <string.h>
int main (void)
{
FILE*f;
fopen_s(&f,"C:\\massiv11","r");
if(f==0)
{
printf_s("no file");
}
int a=0;
while(fscanf_s(f,"%d",&a)!=EOF)
printf_s("%d",a);
fclose(f);
}Решение задачи: «При работе с файлом появляется ошибка debug assertion failed»
textual
Листинг программы
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int count, total = 0;
int buffer;
FILE *stream;
if( (stream = fopen( "C:\\massiv11", "r" )) == NULL )
exit(1);
/* Cycle until end of file reached: */
while (!feof(stream))
{
/* Attempt to read 1 int : */
count = fread(&buffer, sizeof(int), 1, stream);
if (ferror(stream)) {
perror("Read error");
break;
}
printf("%d", buffer);
}
fclose(stream);
}