长时间听众,第一次来电.
如果这个问题已经得到解决,我会道歉(我想这已经被广泛报道),但我已经搜索了很多关于指针和其他看似相关主题的问题,但我仍然无法解决我的问题.
我正在为类项目编写一个字符串库,当我尝试这个时遇到分段错误错误:
#include "str2107.h"
#include <stdio.h>
void lstrip(char *s) {
char *p, *q;
p = q = s;
while (*p == ' ' && *p != '\0') {
*p++;
}
while (*p != '\0') {
*q = *p; //this is where the actual segmentation fault occurs.
p++;
q++;
}
*q = '\0';
}
Run Code Online (Sandbox Code Playgroud)
我的主程序看起来像这样:
#include <stdio.h>
#include <stdlib.h>
#include "str2107.h"
int main(int argc, char** argv) {
char *z1 = " weeee";
printf("lstrip function\n");
printf("%s\n",z1);
lstrip(z1); …Run Code Online (Sandbox Code Playgroud)
我正在使用asp.net Web表单应用程序,我正在尝试以编程方式向自己发送电子邮件.我正在使用Gmail的SMTP客户端,一切都很顺利,但是当我发送邮件时,我收到此错误...
"System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份验证.服务器响应是:5.5.1需要身份验证.了解更多信息"
如果我进入我的Gmail帐户设置并启用允许我访问"安全性较低的应用程序"的选项,一切正常.我想知道如何在启用此选项的情况下发送电子邮件.
protected void sendEmail(object sender, EventArgs e)
{
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new System.Net.NetworkCredential("myusername@gmail.com", "mypassword"),
DeliveryMethod = SmtpDeliveryMethod.Network,
EnableSsl = true
};
MailAddress from = new MailAddress("myusername@gmail.com", "Torchedmuffinz");
MailAddress to = new MailAddress("myusername@gmail.com", "Torchedmuffinz");
MailMessage message = new MailMessage(from, to);
message.Subject = "test";
message.Body = "test";
Attachment attachFile = new Attachment(@"pathtofile");
message.Attachments.Add(attachFile);
try { client.Send(message); }
catch (Exception email_exception)
{
System.Diagnostics.Debug.WriteLine(email_exception);
}
}
Run Code Online (Sandbox Code Playgroud)