Version 6.3 is cused as valid code gcc:
c
gcc
char white[] = { 'a', 'b', 'c' }; char blue[] = "abc"; char *red = "abc";
However, the following is true:
char *green = { 'a', 'b', 'c' }; // gcc error
I am sure that there is a reasonable reason for this, but I wonder what it is. This question is motivated by the fact that when initializing an array of bytes (so unsigned char, not char) it is very tempting to write something like { '\x43', '\xde', '\xa0' }, rather than "\x43\xde\xa0", and as soon as you forget to write my_array[]instead, *my_arrayyou get into the compiler.
unsigned char
char
{ '\x43', '\xde', '\xa0' }
"\x43\xde\xa0"
my_array[]
*my_array
The following will result in an error
char *green = { 'a', 'b', 'c' };
green , . , , . , (.. white), , . , 3 .
green
white
green , , , , . 1
, :
char blue[] = "abc"; char *red = "abc";
blue - . , "abc". red - , "abc".
blue
"abc"
red
:
char *green = (char[]){ 'a', 'b', 'c' };
( ), . .
.
, , .
, , , . , .
, char *, , .
char *
,
char unnamed = { 'a', 'b', 'c', '\0' }; char *red = unnamed;
, .
char *green = ( char[] ){ 'a', 'b', 'c' };
Source: https://habr.com/ru/post/1672728/More articles:Cannot tunnel through proxies. Proxy returns HTTP / 1.1 503 Service Unavailable - javaElasticsearch 5.x Полное текстовое регулярное выражение - elasticsearchJava abstract class with a common parameter that implements its own common parameter - javaWhat is the difference between override_settings and modify_settings in Django? - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1672727/unable-to-capture-changes-to-log-file-via-nagios-checklogwarn-plugin-command-invoked-via-php-exec-triggered-via-jenkins&usg=ALkJrhiULjPst-AjtUxPoLWgc-gln-AtsgVue dynamic html form from Django - django-formsTransactions and Exceptions - phpD3 v4 ajust zoom to center - javascript`onEndReached` не запускается в анимированный ScrollView - androidHow to get visibility / debugging of large memory usage in dotnet Core application running in IIS - c #All Articles