Skip to content

Commit 629e844

Browse files
committed
[HOSTNAME] Use wprintf instead of _cwprintf
_cwprintf always prints to the console and the output is not forwarded like stdout. Fixes "hostname > hostname.txt" and ws2_32:gethostname test.
1 parent 2b1e733 commit 629e844

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

base/applications/cmdutils/hostname/hostname.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
#include <stdlib.h>
10-
#include <conio.h>
10+
#include <stdio.h>
1111

1212
#include <windef.h>
1313
#include <winbase.h>
@@ -39,7 +39,7 @@ int wmain(int argc, WCHAR* argv[])
3939
if (bSuccess)
4040
{
4141
/* Print out the host name */
42-
_cwprintf(L"%s\n", HostName);
42+
wprintf(L"%s\n", HostName);
4343
}
4444

4545
/* If a larger buffer has been allocated, free it */
@@ -50,7 +50,7 @@ int wmain(int argc, WCHAR* argv[])
5050
{
5151
/* Fail in case of error */
5252
LoadStringW(GetModuleHandle(NULL), IDS_ERROR, Msg, _countof(Msg));
53-
_cwprintf(L"%s %lu.\n", Msg, GetLastError());
53+
wprintf(L"%s %lu.\n", Msg, GetLastError());
5454
return 1;
5555
}
5656
}
@@ -60,14 +60,14 @@ int wmain(int argc, WCHAR* argv[])
6060
{
6161
/* The program doesn't allow the user to set the host name */
6262
LoadStringW(GetModuleHandle(NULL), IDS_NOSET, Msg, _countof(Msg));
63-
_cwprintf(L"%s\n", Msg);
63+
wprintf(L"%s\n", Msg);
6464
return 1;
6565
}
6666
else
6767
{
6868
/* Let the user know what the program does */
6969
LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Msg, _countof(Msg));
70-
_cwprintf(L"\n%s\n\n", Msg);
70+
wprintf(L"\n%s\n\n", Msg);
7171
}
7272
}
7373

0 commit comments

Comments
 (0)