Warning: multi-character constant

The warning multi-character constant is generated by the compiler because you assigned more than one character to a char

In reality, the char can take only  one character such as

Letters:  ‘a’

Numbers:  ‘2’

Or special character: ‘@’

Let’s see an example

#include<stdio.h>
int main()
{
    char A='85';
    printf("  %c ",A);
    return 0;
}

As can be seen, from the above code the data type char is assigned by two characters ‘85’

At this time, the compiler will throw a warning because, as i said, the char data type accepts only one character

In case, if you like to assign more characters to the char data type, then, at that instead, you should use string instead of char

A string can handle more characters than, the char

Such as

#include<stdio.h>
int main()
{
    char str[]="hello world";
    printf("%s\n",str);
    return 0;
}

Output

hello world

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.