#Learning and got an error

8 messages · Page 1 of 1 (latest)

mental sparrow
#
#include <stdio.h>


int main() {

    char greet = 'Hello, World';
    printf("%c", greet);

    return 0;
}
``` this is the code and its supposed to print "Hello, World" but im getting an error:
floral stagBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

teal remnant
#
char greet = 'Hello, World';

'c' is for a single character char
"c" is for a string char [n] or char *

terse hound
#

%c is for printing characters

#

use %s to print strings

fickle finch
#
#include <stdio.h>


int main() {

    char greet[20] = "Hello, World";
    printf("%s", greet);

    return 0;
}
#

@OmegaX#9507 try this

floral stagBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.