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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:53:08+00:00 2026-05-16T17:53:08+00:00

#include<iostream> #include<conio.h> using namespace std; int main() { int x = 65; int *ptr

  • 0
#include<iostream>
#include<conio.h>

using namespace std;
int main()
{
           int x = 65;
           int *ptr = &x;
           char * a= (char *)ptr;
           cout<<(int)*(a);
           getch();return 0;
}           

Sixeof(ptr) and Sizeof(a) display 4
Sizeof(int) displays 4 and sizeof(char) displays 1
So 65 is stored in 4 bytes ie
00000000 00000000 00000000 01000001 and address of first bytes is stored in ptr

In the above code I have type casted the int* to char* in a motive to print the value stored in x(type int) first byte.

So after typecasting “a” stores the first byte address ie contained in ptr as well
Now on displaying (int)*a shouldn it consider only first byte for showing the value..??
but the output is 65 instead of 0(first byte value)..Where am I going wrong..?

what I have learnt is

char * ptr1;
ptr1++;  //Ptr1 goes to the next byte..*ptr1 will display only 1 byte value

int  * ptr2;
ptr1++;  //Ptr2 goes to the next 4 byte..*ptr2 will display value conmtain in 4 bytes

PS – I am working on Dev-C++

  • 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-05-16T17:53:08+00:00Added an answer on May 16, 2026 at 5:53 pm

    Your machine is little-endian, and least significant bytes go first.

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

Sidebar

Ask A Question

Stats

  • Questions 540k
  • Answers 540k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your code doesn't get the UTF-8 into memory as you… May 17, 2026 at 2:41 am
  • Editorial Team
    Editorial Team added an answer do yum install db4-devel (or just install the prepackaged openldap,… May 17, 2026 at 2:41 am
  • Editorial Team
    Editorial Team added an answer Are you by any chance blocking the UI thread? There… May 17, 2026 at 2:41 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

#include <iostream> using namespace std; int main() { char buffer[8]; int field=534; memcpy(buffer,&field,sizeof(field)); cout<<buffer<<endl;
#include stdio.h #include conio.h #include <iostream> using namespace std; int main (void) { char
I have a sample code : #include <iostream> #include <conio.h> using namespace std; int
#include <stdio.h> #include <string.h> #include <conio.h> #include <iostream> using namespace std; char a[21]; //
#include <iostream> using namespace std; typedef int MYINT; int main() { int y =
#include <iostream> using namespace std; int main() { int i; for(i=0; i <= 11;
Here the code #include <iostream> #include <conio.h> using namespace std; template <typename T> class
Here is my code - #include <iostream> #include <conio.h> using namespace std; class Base
#include<iostream.h> #include<conio.h> using namespace std; class SpaceShip {}; class GiantSpaceShip : public SpaceShip {};
#include <cstdlib> #include <iostream> int main(int argc, char *argv[]) { cout << "size of

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.