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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:11:53+00:00 2026-06-01T15:11:53+00:00

I was reading a program in C (an implementation of a server/client communication) and

  • 0

I was reading a program in C (an implementation of a server/client communication) and I saw this:

for (i = 0; i < len; i++)
 sprintf(nickmsg+i*2, "%02X", buf[i] & 0xFF);

What does this line do? I don’t understand this especially: nickmsg+i*2.
nickmsg is a char table and i is an integer. If it was just nickmsg, ok I’ll understand but there what’s the aim of this line ?

Thanks.

  • 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-01T15:11:55+00:00Added an answer on June 1, 2026 at 3:11 pm

    Start at the address pointed to by nickmsg and then go an additional i * 2 * CHAR_BIT / 8 bytes in memory. From there, write the hex representation of buf[i] & 0xFF, which will occupy 2 * CHAR_BIT / 8 bytes. Repeat for each i.

    Assuming buf looks like

    buf[0] = 20
    buf[1] = 12
    

    Then the memory pointed to by nickmsg will look like:

    nickmsg
    |
    |
    |
    + + + + +
    0 2 4 6 8
    140C\
    

    Where the \ is my nomenclature for the null-terminator that sprintf writes at the end.

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

Sidebar

Related Questions

I got this error Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading
I'm reading about program specialization - specifically java and I don't think I quite
I have a C++ program that is reading in info from a file, that
I'm writing a small program to record reading progress, the data models are simple:
I am working on a program that requires reading in integers from a file
I'm reading my Deitel, Java How to Program book and came across the term
My C/C++ program takes a file from the command line as an argument. Reading
I have a simple RabbitMQ test program randomly enqueuing messages, and another reading them,
I was reading CLR via C# and it seems that in this example, the
I am creating a file reading program. I need to filter out any char

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.