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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:01:20+00:00 2026-05-30T06:01:20+00:00

Suppose I have these variables, const uint8_t ndef_default_msg[33] = { 0xd1, 0x02, 0x1c, 0x53,

  • 0

Suppose I have these variables,

const uint8_t ndef_default_msg[33] = {
    0xd1, 0x02, 0x1c, 0x53, 0x70, 0x91, 0x01, 0x09,
    0x54, 0x02, 0x65, 0x6e, 0x4c, 0x69, 0x62, 0x6e,
    0x66, 0x63, 0x51, 0x01, 0x0b, 0x55, 0x03, 0x6c,
    0x69, 0x62, 0x6e, 0x66, 0x63, 0x2e, 0x6f, 0x72,
    0x67
};
uint8_t *ndef_msg;
char *ndef_input = NULL;

How can I convert ndef_input (which is just a plain text, like “hello”) to hex and save into ndef_msg?
As you can see ndef_default_msg is in hex form. Data inside ndef_msg should be something like that as well.

A bit of background, in the original program (source code), the program will open a file, get the data and put it inside ndef_msg, which then will be written into a card. But I don’t understand how it can take the data and convert to hex.

I want to simplify the program so it will directly ask user for text (instead of asking for a file).

  • 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-30T06:01:22+00:00Added an answer on May 30, 2026 at 6:01 am

    Why not read it into ndef_msg directly, (minus the \0 if it suppose to be a pure array). The hex are just for presentation, you could have just picked decimal or octal with no consequence for the content.

    void print_hex(uint8_t *s, size_t len) {
        for(int i = 0; i < len; i++) {
            printf("0x%02x, ", s[i]);
        }
        printf("\n");
    }
    
    int main()
    {
        uint8_t ndef_msg[34] = {0};
    
        scanf("%33s", ndef_msg);
        print_hex(ndef_msg, strlen((char*)ndef_msg));
    
    
        return 0;
    }
    

    You probably need to handle the reading of the string differently to allow for whitespace and perhaps ignore \0, this is just to illustrate my point.

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

Sidebar

Related Questions

Suppose we have these local variables: int a = 0; int b = 1;
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
Suppose I have several services represented by classes ServiceA, ServiceB, ServiceC etc. These services
Let's suppose I have these classes: class A(): msg = 'hehehe' class B(A): msg
Suppose I have a C++ class with two private variables. A fixed size array,
Suppose I have class A,B,C; const A a_def; const B b_def; const C c_def;
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Suppose I have a dataset with those two immortal tables: Employee & Order Emp
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily

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.