D
D
DaniilGribanov2022-01-23 03:38:29
C++ / C#
DaniilGribanov, 2022-01-23 03:38:29

How to output TCHAR to a file?

There is a local computer name obtained in this section of code:

string LOCALHOST;
TCHAR HOSTNAME[UNLEN+1];
DWORD HOSTNAME_LEN = UNLEN+1;

LOCALHOST = GetComputerName((TCHAR*)HOSTNAME,&HOSTNAME_LEN);

Another piece of code with the output of the LOCALHOST variable to a file:

string log_path = "log.txt";
  ofstream log;
  log.open(log_path, ofstream::app);
  log << "Имя узла:" << endl;
  log << LOCALHOST << endl;
  log.close();

The log.txt file has the following output:

61eca29c34c62037395388.png
What is the correct way to display the computer name in the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2022-01-23
@galaxy

What does the GetComputerName function return ? (how did this code even compile, I wonder?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question