How to send hex string to serial port?

The thing I want to do is to use serial monitor to input a hex string and send this string to Serial1 port.

For example, I want to send {0x01,0x03,0x0c,0x00} to Serial1 port? Can someone gives me some instruction about it? Thanks!!

My current code is like this and it can't not compile.

byte message[3];
if (Serial.available()>0){
message = Serial.read();
Serial1.write(message);

Yeah that code doesn't compile. It is missing the setup and loop functions ms just has some random code not in any function. Go look at some of he basic tutorials on Arduino and take some time to learn at least the basic structure of a sketch.

This is just a part of my code. I know the setup and the loop functions. Can you give me some instructions about how to send a hex string to the serial1 port. It seems that neither serial1.print nor serial1.write support strings. Thanks!

print definitely supports strings.

But I'm confused, which is why I was hoping to see the rest of the code. The string you describe ( {0x01,0x03,0x0c,0x00} ) contains no printable characters. So my question is, do you want to send those four numbers (1, 3, 12, and 0) or do you want to send an ascii representation of those written out in hex (like send a '0' then a 'x' then a '0' then a '1' etc.

void setup()
{
  Serial.begin(250000);
  byte message[3] = {0x41, 0x42, 0x43};
  Serial.write(message, 3);
}

void loop()
{
}

The above will send 0x41, 0x42 and 0x43 to the serial port (for the example it's Serial, not Serial1). On the serial monitor, you will see ABC.

The first problem with your code is

message = Serial.read();

message is an array of bytes, Serial.read() returns a single value and not an array of bytes.

Note
A number of people are confused about text representations of numeric values; you might be one of them. Do you want to send text representations of the numbers or the numbers themselves (the above code does the latter).