我正在尝试编写一个程序,通过电子邮件将文本消息发送到我的手机,我已经完成了 smtp 和所有爵士乐的处理,所以技术部分已经完成,它可以工作,我只想成为能够在程序中输入我要发送的正文/消息;这就是我所拥有的:
int choice;
cout << "Welcome\n 1:send a text message\n 2:quit\n";
cout << "type either 1 or 2: ";
cin >> choice;
if (choice == 1)
{
const char* message;
cout << "What would you like to send?: ";
cin >> message;
我在 if 语句中设置了邮件发送
mail.SetLogin("******");
mail.SetPassword("********");
mail.SetSenderName("****");
mail.SetSenderMail("***@gmail.com");
mail.SetReplyTo("");
mail.SetSubject("text");
mail.AddRecipient("******@tmomail.net");
mail.SetXPriority(XPRIORITY_NORMAL);
mail.SetXMailer("The Bat! (v3.02) Professional");
mail.AddMsgLine(message);
我收到一条错误消息说 = Error no operator ">>"matches these operands 操作数类型是 std::istream >> const* char
我知道我在为消息设置变量时搞砸了,它正在 #include 库中寻找它,如果有人知道如何解决这个问题,我将非常感激。
顺便说一句,我现在拥有的#includes 是
#include "CSmtp.h"
#include <iostream>
#include <Windows.h>
最佳答案
没有 >>>
重载将文本流式传输到 const char *
。而是使用 std::string
。
关于c++ - 错误没有运算符 ">>"匹配这些操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37342225/