当我向某人发送电子邮件时,(我认为)我的电子邮件被发送到我的家庭服务器,然后该电子邮件被发送到目标服务器,然后最终被发送给我想发送给的人。
有时,这需要多次跳跃,这使我感到困惑。为什么这需要多跳?为什么不能将电子邮件直接发送到目标服务器?例如,XMPP不需要多跳。
我是C++的新手,最近学习函数的指针,对函数指针的使用有点困惑;
我练习了以下代码:
#include <iostream>
#include <sstream>
using namespace std;
int subtraction(int a,int b){
return a-b;
}
int main(int argc, const char * argv[])
{
int (*minus)(int,int)=subtraction;
cout<<minus(5,4);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
效果很好; 所以,我尝试了一点变化:
#include <iostream>
#include <sstream>
using namespace std;
int subtraction(int a,int b){
return a-b;
}
int main(int argc, const char * argv[])
{
int *minus(int,int)=subtraction;//only here different!
cout<<minus(5,4);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在Mac上用Xcode练习它,它给了我错误:
非法初始化程序(只能初始化变量)
但我觉得编译器可以认识到两者是一样的,为什么必须有一对括号?
我对java模式中的限定符用法感到困惑:第一段代码:
private void testRegex(String patternString) {
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher("::::::::");
if (matcher.find()) {
Log.d("regex", matcher.group());
} else {
Log.d("regex", "not match");
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试testRegex(":?"),testRegex(":*"),testRegex(":+")分别; 结果是:
":","::::::::","::::::::";
Run Code Online (Sandbox Code Playgroud)
这是完全正确的我知道,但是:
我在下面尝试另一段代码:
private void testRegex(String patternString) {
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher("sip::::::::");
if (matcher.find()) {
Log.d("regex", matcher.group());
} else {
Log.d("regex", "not match");
}
}
Run Code Online (Sandbox Code Playgroud)
结果是:
""(empty String),""(empty String),"::::::::"
Run Code Online (Sandbox Code Playgroud)
谁能告诉我地球上发生了什么?先感谢您!
我正在处理有关IM的事情.它涉及XMPP.我在Android上开发了一个应用程序,所以我使用了一个思科.我想登录google talk,在这里(链接如下)
https://developers.google.com/talk/open_communications
谷歌说只支持SASL PLAIN.但是当我在INTERNET上搜索时,很多人都认为google talk不支持SASL,所以需要这段代码:
connectionConfig.setSASLAuthenticationEnabled(false);
Run Code Online (Sandbox Code Playgroud)
我很迷惑; 谁能告诉我哪个是正确的,或SASL和SASL PLAIN之间的区别?
我执行这样的命令
echo 'int main(){printf("%lu\n",sizeof(void));}' | gcc -xc -w -&& ./a.out
Run Code Online (Sandbox Code Playgroud)
并且可以得到结果:1.但我无法找到 - &&的意思,甚至在搜索手册页和谷歌之后!并且我尝试在没有 - && option.it的情况下执行它将是这样的错误:
./a.out:1: error: stray ‘\317’ in program
./a.out:1: error: stray ‘\372’ in program
./a.out:1: error: stray ‘\355’ in program
./a.out:1: error: stray ‘\376’ in program
./a.out:1: error: stray ‘\7’ in program
./a.out:1: error: stray ‘\1’ in program
./a.out:1: error: stray ‘\3’ in program
./a.out:1: error: stray ‘\200’ in program
./a.out:1: error: stray ‘\2’ in program
./a.out:1: error: stray ‘\16’ in program
./a.out:1: error: expected identifier …Run Code Online (Sandbox Code Playgroud) 我的程序有两个线程,每个线程打印十个数字。第一个线程打印奇数,第二个线程打印偶数,然后轮流打印数字。我期望得到一个像1,2,3,4,5 ....直到20的序列,但是该程序会产生一个IllegalMonitorStateException。
我知道此异常的含义,但是我在和同步块中使用wait()和notify()。这是我的代码:
public class EvenOddThreadTest {
/**
* @param args
*/
static Object obj1 = new Object();
static Object obj2 = new Object();
static Object obj3=new EvenOddThreadTest();
public static void main(String[] args) throws InterruptedException {
new Thread() {
@Override
public void run() {
for (int i = 1; i < 21; i += 2) {
synchronized (obj1) {
System.out.println(i + Thread.currentThread().getName());
try {
obj2.notify();
obj1.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} …Run Code Online (Sandbox Code Playgroud)