User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:wchar.h:fgetwc

fgetwc

   #include <wchar.h>
   wint_t fgetwc(FILE *);

fgetwc Description

fgetwc reads in a single character from Stream and returns its value as a wide character.

C Sourcecode Example

/* 
 * fgetwc example code
 * http://code-reference.com/c/wchar.h/fgetwc
 */
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#include <wchar.h>
 
int main( void )
{
    FILE* stream = fopen("testmb.txt", "r");
 
    if (!stream) {
        printf("Could not open the file\n");
        return 1;
    }
 
    wchar_t wchar = fgetwc(stream);
    if (wchar != WEOF) {
        printf("char read: %c\n", wchar);
    } else {
        printf("read error\n");
    }
    fclose(stream);
 
    return 0;
}

content of testmb.txt

testmb.txt
A
B
C

output

  A

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/wchar.h/fgetwc.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz