C Tutorial/Wide Character String/Wide Character String Terminator

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Add string terminator to wide character string

#include <stdio.h>
#include <wchar.h>
int main(void)
{
  wchar_t text[100];
  printf("\nEnter the string to be searched(less than 100 characters):\n");
  fgetws(text, 100, stdin);
  text[wcslen(text)-1] = L"\0";
  printf("\nFirst string entered:\n%S\n", text);
}
Enter the string to be searched(less than 100 characters):
asdf
First string entered:
asdf