Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:44:10+00:00 2026-06-06T19:44:10+00:00

I am learning C++ and have got a question that I cannot find the

  • 0

I am learning C++ and have got a question that I cannot find the answer to.

What is the difference between a char constant (using single quotes) and a string constant (with double quotes)?

All my search results related to char arrays vs std::string. I am after the difference between 'a' and "a".

Would there be a difference in doing the following:

cout << "a";
cout << 'a';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:44:11+00:00Added an answer on June 6, 2026 at 7:44 pm

    'a' is a character literal. It’s of type char, with the value 97 on most systems (the ASCII/Latin-1/Unicode encoding for the letter a).

    "a" is a string literal. It’s of type const char[2], and refers to an array of 2 chars with values 'a' and '\0'. In most, but not all, contexts, a reference to "a" will be implicitly converted to a pointer to the first character of the string.

    Both

    cout << 'a';
    

    and

    cout << "a";
    

    happen to produce the same output, but for different reasons. The first prints a single character value. The second successively prints all the characters of the string (except for the terminating '\0') — which happens to be the single character 'a'.

    String literals can be arbitrarily long, such as "abcdefg". Character literals almost always contain just a single character. (You can have multicharacter literals, such as 'ab', but their values are implementation-defined and they’re very rarely useful.)

    (In C, which you didn’t ask about, 'a' is of type int, and "a" is of type char[2] (no const)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning the Definitive Guide of JavaScript.i got a question about the
i have done some learning on struts based on one project that i got.Now
Hi there Im just learning JSF 2 using Primefaces. I have a question regarding
got a question regarding serializing classes that I've defined. I have some classes like
Right, day 8 learning php and I feel that I have tried to do
Sorry for asking a basic question, I am learning C and I got confused
I've been broadening my horizons learning javascript and I have a quick question about
I've been learning my way around WCF and I've got a question regarding the
I have trouble using Perl grep() with a string that may contain chars that
Question Where can I find really good, thorough and comprehensive Android development instruction that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.