put string in byte array

hello every one i have a code that has challenged me for a long time.
i have a string like : 000000000000000000000000000f0111
now what i want is to put each two pairs of this string in a byte array like this:

 byte dataBlock[]    = {
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 
        0x00, 0x00, 0x00, 0x00, 
        0x00, 0x0f, 0x01, 0x11  
    };

please help me this is urgent.
i managed to split this string in two pairs but i can not figure out the rest!

Your term "string" is too ambiguous. Show your code that creates the "string".

this is my code it is a bit messy but at leadt shows all the thins a have tried since far.

 String remaingsesssion;
            block=2;
             readBlock(block, readbackblock);
             Fflag=0;
               for (int j=0 ; j<16 ; j++)//print the block contents
         {
          //if (readbackblock[j]==0)
         // Serial.write ("i="+j);
           Serial.println (readbackblock[j],HEX);//Serial.write() transmits the ASCII numbers as human readable characters to serial monitor
           
         if(readbackblock[j]=="F"||readbackblock[j]=="F "||readbackblock[j]==" F"){
            Serial.println ("F was found");
            }else
            Serial.println ("F was not found");
            //*************=**********************************////
             myString = String(readbackblock[j],HEX);
             Serial.println (myString);
             if(myString=="f"||myString=="f0"||myString=="0f"||myString=="F"||myString=="0F"||myString=="F0"){
            Serial.println ("F was found");
            for(int k=j;k<16;k++){
              remaingsesssion=remaingsesssion+String(readbackblock[k],HEX);
              Serial.println("remaining Session: "+remaingsesssion);
              }

         }
            }
            int charplc;
            
            charplc = remaingsesssion.indexOf("f");
            remaingsesssion.remove(charplc, 1);
            int remainSession=0;
            remainSession=remaingsesssion.toInt();
            Serial.println("remaining Session:");
            Serial.println(remainSession);
            int tempSession;
            tempSession=remainSession;
            if (tempSession<0)
            myString = "0"+String(remainSession);
            else
            myString =String(remainSession);
            int Strlen;
          //  Strlen=myString.length();
           // char blockcontent[16];
          //  writeBlock(block, blockcontent[16]);
          //  delay(200);
           // String SaveStr="";
           // for(int i=0;i<32-(Strlen+2);i++){
            //  SaveStr=SaveStr+0;
            //  }
              
              
            //  SaveStr=SaveStr+"f0";
            //  SaveStr=SaveStr+myString;
            //  Serial.print("SaveStr:"+SaveStr);
           //   for(int i=0;i<32;i=i+2){
              // if(i==0)
              //  blockcontent[i]=myString.substring(i, 1);
                //  else
               //  blockcontent[i-1]=myString.substring(i, i+2); 
             //  blockcontent[i]=0xmyString.substring(i, 1);
             //   }
             //   SaveStr.toCharArray(blockcontent[32],32);
           //  Serial.print(blockcontent);
           // writeBlock(block,blockcontent[16]);

taymaz1990:
this is my code it is a bit messy

It's also incomplete and does not compile.

this is a part of my code you need an rc522 rfid module in order to run that with no errors. i just received a code using this and saved it as a string the code that i received is a number and i want to decrease that and send it again through module to my rfid card. the string that i mentioned first is the one that is received from module. now for sending it, it must be in byte array as the library needs it. now i dont know how to do it. the full code is this:
i want to put "string a" in "byte dataBlock[]"

/**
 * ----------------------------------------------------------------------------
 * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
 * for further details and other examples.
 *
 * NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
 *
 * Released into the public domain.
 * ----------------------------------------------------------------------------
 * This sample shows how to read and write data blocks on a MIFARE Classic PICC
 * (= card/tag).
 *
 * BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7).
 *
 *
 * Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS      SDA(SS)      10            53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 *
 */

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         9           // Configurable, see typical pin layout above
#define SS_PIN          10          // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

MFRC522::MIFARE_Key key;

/**
 * Initialize.
 */
void setup() {
    Serial.begin(9600); // Initialize serial communications with the PC
    while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
    SPI.begin();        // Init SPI bus
    mfrc522.PCD_Init(); // Init MFRC522 card

    // Prepare the key (used both as key A and as key B)
    // using FFFFFFFFFFFFh which is the default at chip delivery from the factory
    for (byte i = 0; i < 6; i++) {
        key.keyByte[i] = 0xFF;
    }

    Serial.println(F("Scan a MIFARE Classic PICC to demonstrate read and write."));
    Serial.print(F("Using key (for A and B):"));
    dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE);
    Serial.println();

    Serial.println(F("BEWARE: Data will be written to the PICC, in sector #1"));
}

/**
 * Main loop.
 */
void loop() {
    // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
    if ( ! mfrc522.PICC_IsNewCardPresent())
        return;

    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial())
        return;

    // Show some details of the PICC (that is: the tag/card)
    Serial.print(F("Card UID:"));
    dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
    Serial.println();
    Serial.print(F("PICC type: "));
    MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
    Serial.println(mfrc522.PICC_GetTypeName(piccType));

    // Check for compatibility
    if (    piccType != MFRC522::PICC_TYPE_MIFARE_MINI
        &&  piccType != MFRC522::PICC_TYPE_MIFARE_1K
        &&  piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
        Serial.println(F("This sample only works with MIFARE Classic cards."));
        return;
    }

    // In this sample we use the second sector,
    // that is: sector #1, covering block #4 up to and including block #7
    byte sector         = 1;
    byte blockAddr      = 4;
    String a = "0000000000000000000000000000f011";
    byte dataBlock[]    = {
        0x01, 0x02, 0x03, 0x04, //  1,  2,   3,  4,
        0x05, 0x06, 0x07, 0x08, //  5,  6,   7,  8,
        0x09, 0x0a, 0xff, 0x0b, //  9, 10, 255, 11,
        0x0c, 0x0d, 0x0e, 0x0f  // 12, 13, 14, 15
    };
   // dataBlock[0]=a.HEX;
    byte trailerBlock   = 7;
    MFRC522::StatusCode status;
    byte buffer[18];
    byte size = sizeof(buffer);

    // Authenticate using key A
    Serial.println(F("Authenticating using key A..."));
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("PCD_Authenticate() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
        return;
    }

    // Show the whole sector as it currently is
    Serial.println(F("Current data in sector:"));
    mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
    Serial.println();

    // Read data from the block
    Serial.print(F("Reading data from block ")); Serial.print(blockAddr);
    Serial.println(F(" ..."));
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("MIFARE_Read() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
    }
    Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":"));
    dump_byte_array(buffer, 16); Serial.println();
    Serial.println();

    // Authenticate using key B
    Serial.println(F("Authenticating again using key B..."));
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("PCD_Authenticate() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
        return;
    }

    // Write data to the block
    Serial.print(F("Writing data into block ")); Serial.print(blockAddr);
    Serial.println(F(" ..."));
    dump_byte_array(dataBlock, 16); Serial.println();
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(blockAddr, dataBlock, 16);
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("MIFARE_Write() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
    }
    Serial.println();

    // Read data from the block (again, should now be what we have written)
    Serial.print(F("Reading data from block ")); Serial.print(blockAddr);
    Serial.println(F(" ..."));
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("MIFARE_Read() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
    }
    Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":"));
    dump_byte_array(buffer, 16); Serial.println();

    // Check that data in block is what we have written
    // by counting the number of bytes that are equal
    Serial.println(F("Checking result..."));
    byte count = 0;
    for (byte i = 0; i < 16; i++) {
        // Compare buffer (= what we've read) with dataBlock (= what we've written)
        if (buffer[i] == dataBlock[i])
            count++;
    }
    Serial.print(F("Number of bytes that match = ")); Serial.println(count);
    if (count == 16) {
        Serial.println(F("Success :-)"));
    } else {
        Serial.println(F("Failure, no match :-("));
        Serial.println(F("  perhaps the write didn't work properly..."));
    }
    Serial.println();

    // Dump the sector data
    Serial.println(F("Current data in sector:"));
    mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
    Serial.println();

    // Halt PICC
    mfrc522.PICC_HaltA();
    // Stop encryption on PCD
    mfrc522.PCD_StopCrypto1();
}

/**
 * Helper routine to dump a byte array as hex values to Serial.
 */
void dump_byte_array(byte *buffer, byte bufferSize) {
    for (byte i = 0; i < bufferSize; i++) {
        Serial.print(buffer[i] < 0x10 ? " 0" : " ");
        Serial.print(buffer[i], HEX);
    }
}

You're not using a "string", you're using the "String" class. Why? There's a big difference between the two that you need to understand.

You'd be better off by using "strings" (aka c-strings, aka null-terminated char array) to begin with. Then the "conversion" would be trivial.

can you please explain more about it! actually im not so professional in programming.

Here are just a few of the Google hits for "c-string".

http://www.cplusplus.com/reference/cstring/

ok what i did know is that i have redefined 'String a' as 'char a[]' and i could do this math is my code 'dataBlock[0]=a[0];' in compiles with no error but when i use serial print to see the result the output is 48! and there is another problem and that is the length of array my blockdata array length is 16 and my char array length is 32 thus to fit this char array in byte array i have got to put each 1 pair of char array members in blockdata array. is it possible? if it is possible please help me to solve this and all my problem is solved.

thank you for your help i found the answer in this link below but it was your help that lead me there.