A
A
Andrey2018-10-06 02:05:23
C++ / C#
Andrey, 2018-10-06 02:05:23

What is the error when trying to read from a stream in SI?

List of errors:

1>d:\secret\secret\secret.c(12): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\ucrt\stdio.h(207): note: see "fopen" declaration

#include <stdio.h>
#include <string.h>
#include <locale.h>

int main() {
  
  setlocale(LC_ALL, "Russian");

  int N = 10, start = 2, i, val, j;
  FILE *F;

  if ((F = fopen("output.txt", "a")) == NULL) {
    printf("File 'output.txt' - not found.\n");
  }

  for (i = 0; i < N; i++) {
    val = start;

    printf("VALUE: %d\n", val);
    fprintf(F, "VALUE: %d\n", val);

    for (j = 0; val != 1; j++) {
      if (val % 2 == 0) {
        printf("\tЧ: %d/2", val);
        fprintf(F, "\tЧ: %d/2", val);
        val = val / 2;
        printf("=%d\n", val);
        fprintf(F, "=%d\n", val);
      }
      else {
        printf("\tН: %d*3+1", val);
        fprintf(F, "\tН: %d*3+1", val);
        val = val * 3 + 1;
        printf("=%d\n", val);
        fprintf(F, "=%d\n", val);
      }
    }
    fclose(F);
    start++;
  }

  return 0;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sokolov, 2018-10-06
@officialandrey

Try to translate the text from the error into Russian:
This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question