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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:37:08+00:00 2026-06-03T08:37:08+00:00

char data_[4096]; … socket_.async_read_some(boost::asio::buffer(data_, 4096), boost::bind(&client::handle_read_header, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); when function handle_read_header is fired,

  • 0
char data_[4096];
...
socket_.async_read_some(boost::asio::buffer(data_, 4096),
    boost::bind(&client::handle_read_header, this,
    boost::asio::placeholders::error,
    boost::asio::placeholders::bytes_transferred));

when function handle_read_header is fired, data_ contains many \0 symbols in text.
with help of which way is it easier to view full (with stripped or escaped \0) string by std::cout? (by default \0 make end of string and don’t show other)

  • 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-03T08:37:09+00:00Added an answer on June 3, 2026 at 8:37 am

    Seth kindly pointed out your requirement to make it “easier to view”. For that:

    for (size_t i = 0; i < num_bytes; ++i)
        if (buffer[i] == '\\')
            std::cout << "\\\\";
        else if (isprint(buffer[i]))
            std::cout << buffer[i];
        else
            std::cout << '\\' << std::fill(0) << std::setw(3) << buffer[i];
    

    The above uses 3-digit back-slash escaped octal notation to represent non-printable characters. You can change the representation easily enough.

    (For a simple binary write, you can call std::cout.write(buffer, num_bytes) to do a binary block write, rather than std::cout << buffer which relies on the ASCIIZ convention for character arrays/pointers. Then you could pipe the result into less, cat -vt or whatever your OS provides that helps view binary data including NULs.)

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

Sidebar

Related Questions

char **Data[70]={NULL}; What is the correct terminology for this? How else could it be
I have char* data; which has a buffer dumped into it. I want to
I've got this simple piece of code: char data[4] = { 0x13, 0x34, 0xad,
Im sending data on network via sockets like this: (broadcast) void sendBroad(char *dstIP, char
I have this array: unsigned char* data = CGBitmapContextGetData(cgctx); then I tried to get
Ok, I'm really confused by this behaviour in VS2008. This code.. char data[512] =
I have a char * buffer that is filled by an API function. I
Can someone explain this to me: char* a; unsigned char* b; b = a;
unsigned char* Data::getAddress(unsigned char* address) { strcpy((char*)address, (char*)this->_address); return (unsigned char*)address; } int main()
Can you explain this: void foo(const char data[10]) { char copy[10]; const char copy1[10]

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.