In C/C++, what's the difference between the following two line code:
char *str1="hello";
char *str2={"hello"};
Hi is equivalent to hello, but it is considered a little bit more informal in tone. In fact, it was recorded a lot earlier than hello. Hi developed from the Middle English hy, similar to hey and ha.
HELLO is a word you use to show that you are happy to see or meet someone. For example: "Hello, my name is Tom and I'm the new kid." HI has the same meaning, but it is more informal. For example: "Hi John!
Per the 2011 C standard, clause 6.7.9 Initialization, paragraph 11: “The initializer for a scalar shall be a single expression, optionally enclosed in braces…”
That is it. There is no semantic difference; the braces simply may be present or may be absent, with no change to the meaning.
Style only in this case. They both result in the same thing, and they're both bad form. You should have used const char * str1="hello";
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With