如何在静态const char中设置变量?

时间:2019-02-21 20:12:43

标签: c++ libcurl

我正在遵循以下代码:

https://github.com/curl/curl/blob/master/docs/examples/smtp-tls.c

在C ++环境中使用它,我想向电子邮件本身添加变量。例如:

static const char *payload_text[] = {
  "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
  "To: " TO "\r\n",
  "From: " FROM " (Example User)\r\n",
  "Cc: " CC " (Another example User)\r\n",
  "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
  "rfcpedant.example.org>\r\n",
  "Subject: SMTP TLS example message\r\n",
  "\r\n", /* empty line to divide headers from body, see RFC5322 */
  "This message is being sent because ", reason, "\r\n",
  NULL
};

“原因”可能有很多种,从提醒到指示用户违反了规则等,我无法在其中输入字符串,所以我想知道如何才能在消息中添加变量。

编辑:我也希望能够允许用户在变量上进行输入。这是我当前的消息:

const char *user = {
    "John Doe"
};

const char *reason = {
    " this is a test."
};

static const char *payload_text[] = {
  "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
  "To: " TO "\r\n",
  "From: " FROM " (Example User)\r\n",
  "Cc: " CC " (Another example User)\r\n",
  "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
  "rfcpedant.example.org>\r\n",
  "Subject: SMTP TLS example message\r\n",
  "\r\n", /* empty line to divide headers from body, see RFC5322 */
  "Hi, ", user, " you have received this message because " , reason "\r\n",
  NULL
};

我只是想弄清楚用户和程序如何确定这些变量。

0 个答案:

没有答案