Questions tagged [string-literals]

String literals concern the syntactic representation of literal constant strings in C, C++ and others.

C and C++ have several ways to represent strings in code. They include the basic double quoted "Hello, World!". Strings can be concatenated "as" " follows". C++-0X has added new encodings u"Hello" for UTF16 (char16_t), U"world" for UTF32 (char32_t) is addition to L"long" for wchar_t. There are rules for concatenating different encodings.

1193 questions
-5
votes
2 answers

What is the difference between char *exp="a+b" and char exp[]="a+b"? Are they stored the same way in memory or they differ?

Also, why we can't use int *exp = [1,2,3] for creating an array of integers using pointers if we can use char *exp?
-5
votes
2 answers

Strange outputs char in C (This is not typo)

Please explain what is going on. I am unable to make sense of the output. #include int main() { char c="c"; printf("%c",c); return 0; } Also what will be the output when c="false", "e",'false' etc I wish to understand whats…
-5
votes
1 answer

Which string constructor is invoked?

I know this is initialization but I am confused which of the 2 constructors is invoked when a string literal is used in each case. Are they both copy constructors? string::string(const string& strString) string::string(const char…
softwarelover
  • 1,009
  • 1
  • 10
  • 22
-5
votes
3 answers

how is the output of the statement is 'E'

#include main() { printf("ABCDE" + sizeof("ABC");/*please explain the output*/ } Output of the program is E compiled with gcc, please explain
-5
votes
5 answers

Differences between single-quotes and double-quotes in C

Recentely I have seen that if I use printf with 'foo' I get a warning. printf('numero'); warning: character constant too long for its type [enabled by default] warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast.…
salajadin
  • 11
  • 1
  • 5
-6
votes
1 answer

why am i getting segmentation fault core dumped?

i'm getting segmentation fault core dumped when im using strtok at the next code part. the code is getting debugged but when I run it I get the segmentation fault. How can I fix it? struct{ char…
-6
votes
2 answers

Does typecasting if a conditional statement differ from typecasting in a regular C expression?

#include int main() { switch(*(1+"AB""CD"+1)) { case'A':printf("Pulp Fiction"); break; case'B':printf("12 Angry Man"); break; case'C':printf("Casabance"); break; …
jeet
  • 9
  • 3
-9
votes
2 answers

How to explain the C code: char *s = "hello " "world";

I tried the following C code by accident: char *str = "hello " "world"; It's right, but I can't understand. How to explain this instrument?
L.T
  • 1
  • 1
1 2 3
79
80