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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:02:35+00:00 2026-06-06T04:02:35+00:00

#include <iostream> #include <iomanip> using namespace std; int main() { char array[10]; for(int i

  • 0
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    char array[10];

    for(int i = 0; i<10;i++)
    {
        array[i] = 'a' + i;
    }

    char* test = array;

    printf("%x\n", test);
    cout << hex << test << endl;

}

The output for this is:

bffff94e
abcdefghijN???

Why is it not printing the same thing?

  • 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-06T04:02:39+00:00Added an answer on June 6, 2026 at 4:02 am
    cout << hex << test << endl; 
    

    It prints the string, not the address. It is because there is an overload of operator<< which takes char const* as argument and this overload treats the argument as string.

    If you want to print the address, cast the argument to void* so that other overload of operator<< will be invoked which will print the address.

    cout << hex << static_cast<void*>(test) << endl;
    

    will print the address, in hexadecimal format.

    Note that hex stream-manipulator is not needed here, as the address will be printed in hexadecimal format anway. So

    cout << static_cast<void*>(test) << endl;
    

    is enough.

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

Sidebar

Related Questions

#include<iostream> #include<fstream> #include<cstdlib> #include<iomanip> using namespace std; int main() { ifstream in_stream; // reads
#include <iostream> using namespace std; int main() { int a, b, c, max; cout<<a=;
#include <iostream> #include <iomanip> using namespace std; double distance(double, double); int main () {
#include <iostream> #include <string.h> using namespace std; int main() { int e=0; int b=0;
#include<iostream> #include<stdlib.h> #include<string.h> #include<stdio.h> using namespace std; union type{ int a; char b; int
#include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <string> using namespace std; int
Here is my code: #include <iomanip> #include <fstream> #include <iostream> using namespace std; int
#include stdafx.h #include <iomanip> #include <iostream> #include <fstream> using namespace std; void FillArray (int
#include <iostream> #include <string> using namespace std; string crash() { } int noCrash() {
#include <iostream> #include <iomanip> #include <stdio.h> #include <windows.h> #include <process.h> using namespace std; HANDLE

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.