OiO.lk Blog C# Multi-character character constant [-Wmultichar] Error in C
C#

Multi-character character constant [-Wmultichar] Error in C


#include <stdio.h>
main ()
{
    int c;
    while ((c = getchar()) != EOF ) {
        if (c == '\t') {
            while ((c = getchar()) == '\t');
                putchar ('\\t');
        }
        else (c == '\b') {
            while ((c = getchar()) == '\b');
                putchar ("\\b");
        }
        else (c == '\\' ) {
            while ((c = getchar()) == '\\');
                putchar ("\\");
        }
        putchar(c);
    }
}

I get the following error when trying to compile:

cpytbb.c: In function ‘main’:
cpytbb.c:8:14: warning: multi-charactercharacter constant [-Wmultichar]
cpytbb.c:10:20: error: expected‘;’ before ‘{’ token

Please note that the second error is probably irrelevant to the issue. I’m new and I most likely have done some mistakes in my code.

In case it’s needed, I’m using gcc.

Edit: I’m trying ‘print’ out \t \b and \ as simple text. As an example if I hit ‘backspace’ it will print \b



You need to sign in to view this answers

Exit mobile version