Now I am facing a problem as shown below:
int foo(void){ char a[10] = "foo"; char b[10] = {"foo"}; ... }
I used gdb to check the contents of both "a" and "b", and they looked exactly the same.
Is there a difference between a and b?
They are the same:
C11 ยง6.7.9 InitializationA character type array can be initialized with a character string literal or a UTF-8 string literal , optionally enclosed in braces. Sequential bytes of a string literal (including a terminating null character, if any, or if an array of unknown size) initialize the elements of the array.
A character type array can be initialized with a character string literal or a UTF-8 string literal , optionally enclosed in braces. Sequential bytes of a string literal (including a terminating null character, if any, or if an array of unknown size) initialize the elements of the array.
, . :
:
(strcmp(a,b)==0) ? cout << "Same" : cout << "Diff";
(a==b) ? cout << "Same" : cout << "Diff";
Source: https://habr.com/ru/post/1529919/More articles:Weight chart in Neo4j - java"No viable overloaded" = "why"? - c ++Write a new line in a txt file with PHP? - htmlJavaFX inline scene scene - javaHow to create a custom 3d model in JavaFX 8? - javafx-2Tkinter set focus on Entry widget - 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/1529921/is-it-appropriate-to-use-extension-methods-to-map-one-class-to-another&usg=ALkJrhjo8t_7lb5_vyaCeCqEHUOrzbItAwthe file is โcorrupted and cannot be openedโ when opening a double-attached file - fileGCC C ++ 11 Condition Variables Waiting for Internal - c ++Resizing images with CGImageCreate to reduce memory usage - iosAll Articles