R
R
Reslyukov Alexander2021-06-10 18:42:06
C++ / C#
Reslyukov Alexander, 2021-06-10 18:42:06

How to display variables in a text document?

In general, according to the assignment, the values ​​​​of the matrix after summation should be output to a txt file in a certain order.
As I understand it, this is done through FILE and fopen, but can someone specifically parse everything in detail? Thanks in advance for your replies.
PS on the example of just some two variables

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LoliDeveloper, 2021-06-10
@Alexandr_202

int a = 0; //переменная
int b = 0; //переменная

FILE* file = fopen("file.txt", "w"); //открытие файла с разрешением на запись
fprintf(file, "%d %d ", a, b);//запись в файл формат-строкой с пробелами

fclose(file); // закрытие файла

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question