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 7991039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:10:51+00:00 2026-06-04T13:10:51+00:00

I am wondering how come the sizeof function returned 8 no matter the length

  • 0

I am wondering how come the sizeof function returned 8 no matter the length of my input

int main(){
   string input;
   getline(cin,input);
   cout << "size of input is  " << sizeof(input) << endl; //I am guessing 
//it returns the size of a pointer because my OS is 64 bits.
   return 0;
}

So my question is that where the implicit conversion happened? here is the declaration of getline,

istream& getline ( istream& is, string& str );

Also, this sort of conversion always happen, i.e from whatever to a pointer type, is there a general case for that? Thank you.

  • 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-04T13:10:53+00:00Added an answer on June 4, 2026 at 1:10 pm

    sizeof gives you the size in bytes. std::string contains a pointer to the actual data. The size of the single pointer stays the same no matter the size of what it’s pointing to. This, combined with the other factors gives you your total size of 8.

    You’re looking for either std::string::size or std::string::length for the actual length of the string. If you’re looking for a function to retrieve the size of any null-terminated C-String, use strlen().

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

Sidebar

Related Questions

I have come accross to this function below and I am wondering wether this
I am wondering whether any of you have ever come accross a solution/function that
I was wondering if anybody had come across a good way to validate string-arrays
I was wondering has anyone come across thos error in SIP before? WARN/System.err(4623): javax.sip.SipException:
I'm wondering if anyone has ever come across a plug-in for mootools that will
I am wondering if anyone has come across a way to generate tones in
I’m just wondering if anyone’s come across or could recommend an IDE that’s capable
I've come across a Registry Class and I'm wondering whether to bother with this
I have come across Evernote's bookmarklet and was wondering how this worked. You can
I was just wondering if anyone has come across anything offering similar search functionality

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.