N
N
nikbond2015-12-07 23:31:40
C++ / C#
nikbond, 2015-12-07 23:31:40

C: how to print pseudographics to a file?

It outputs the character corresponding to the asci-code (in this case, any pseudo-graphics) to the console, but for some reason it prints Cyrillic to the file. How to print pseudographics to a file?

#include <stdio.h>
int main(){
    FILE * pF = fopen("output.txt", "w");
    char black = 219; /*аски код черного квадратика */
    printf("%c\n", black); /*нормально*/
    fprintf(pF, "%c\n", black ); /*лажа, выводит 'Ы' */
 
    return 0;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Ocelot, 2015-12-07
@nikbond

Most likely, everything is written to the file correctly - check with a HEX editor. It's just that the program in which you then open the file to look at the result uses a Cyrillic code page instead of pseudographics, probably CP1251. Put CP866 - you will have black squares.

A
anikavoi, 2015-12-09
@anikavoi

int main(){
system("chcp 1251"); // Since the output is to the console - switch the console to cp1251
... then the same thing ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question