c language arrangement

Asked 2 years ago, Updated 2 years ago, 72 views

#include <stdio.h>
int main(void) {
    char ar[] = {"a","b","c","d","e","f","/0"};
    printf("%s\n", ar);
    return 0;
}

I wrote it like this In Visual Studio, "You cannot initialize an entity in the "char *" format using a value in the "const char *" format," and when I turned on the code executor, the original abcdef was supposed to come out, but only a came out. This is language c. Please help me

array c visual-studio

2022-09-22 18:27

1 Answers

1 character in c must be enclosed in '', not ''.

And your character representation is also \0, not /0.

Please modify it as below and try it.

char ar[] = {'a','b','c','d','e','f', '\0'};


2022-09-22 18:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.