我的部分代码:
int server_sockfd, client_sockfd; //socket file descriptors of client and server
// ... some code
if(pthread_create(&vlakno, NULL, handle_client, (int *) client_sockfd) != 0) {
perror("Error while creating thread.");
}
Run Code Online (Sandbox Code Playgroud)
我正在收到"警告:从不同大小的整数转换为指针[-Wint-to-pointer-cast]"
我的功能原型:
void *handle_client(void *args);
Run Code Online (Sandbox Code Playgroud)
我发现了这个问题:
链接
第一个答案说他应该使用intptr_t而不是int.
我有两个问题:
在我的情况下int和intptr_t
有什么区别?
我该怎么办?
我有2个想法:
第1 :(更改文件描述符的类型)
int server_sockfd, client_sockfd; //socket file descriptors of client and server
// ... some code
if(pthread_create(&vlakno, NULL, handle_client, (intptr_t *) client_sockfd) != 0) {
perror("Error while creating thread.");
}
Run Code Online (Sandbox Code Playgroud)
或第二个想法:(仅在铸造函数pthread_create中更改类型)
intptr_t server_sockfd, client_sockfd; //socket file …Run Code Online (Sandbox Code Playgroud)
我收到错误:格式异常未处理,输入字符串格式不正确.
对于这一行:
int right = System.Convert.ToInt32(rightAngleTB.Text);
Run Code Online (Sandbox Code Playgroud)
rightAngleTB是TextBox,值Text是"25"(不带"").
我真的没有看到问题:(
我有类(JavaBean,如果你想这样称呼它)
class Tweet{
private millis; //number of millis since 1970
//other attributes and getters and setters, but i want to sort onlny by millis
public long getMillis() {
return millis;
}
}
Run Code Online (Sandbox Code Playgroud)
比较器应该看起来像这样:
class TweetComparator implements Comparator {
@Override
public int compare(Tweet t1, Tweet t2) {
//something
//this doesn't work
//return t2.getMillis().compareTo(t1.getMillis());
return ??;//what should be here?
}
}
Run Code Online (Sandbox Code Playgroud)
这将在程序中
List<Tweet> tweets = new ArrayList<Tweet>();
tweets.add(...); //just fill the list
//i need newest (with hightest millis value first) so I …Run Code Online (Sandbox Code Playgroud) 如何在freemarker中连接字符串?
这行不通。
<#function foo input>
<#local str="Hello ">
${str} = ${str} + ${" world"}
<#return str>
</#function>
${foo("a")}
Run Code Online (Sandbox Code Playgroud)
这是在线评估者:http :
//freemarker-online.kenshoo.com/
编辑:为了清楚起见,我需要将其与变量一起使用,以便能够编写类似这样的内容。
public String sayHello() {return "Hello";}
public String sayWorld() {return "world"};
public String sayPeople() {return "people";}
public void main() {
String str = "";
str += sayHello();
str += "";
str += sayWorld();
str += "";
str += sayPeople();
return str;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 set 来定义某些操作的允许键。Eclipse 显示此警告:
Type safety: The expression of type List needs unchecked conversion
to conform to Collection<? extends Object>
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索了一下,在略有不同的情况下发现了相同的消息,但可能是类似的问题。
有没有机会以其他方式摆脱这个警告
@SuppressWarnings("unchecked")
Run Code Online (Sandbox Code Playgroud)
是个好主意
@SuppressWarnings("unchecked")
Run Code Online (Sandbox Code Playgroud)
在这种情况下?
这是我的代码:
public static final String KEY_A = "A_VALUE";
public static final String KEY_B = "B_VALUE";
public static final Set<?> allowedKeys = new HashSet<Object>(Arrays.asList(new String[] {KEY_A, KEY_B}));
Run Code Online (Sandbox Code Playgroud) 我使用Java 7 Servlets和Tomcat 7作为服务器,使用MySQL作为数据库.我正在尝试对用户进行一些搜索,但是我的SQL中可能存在一些问题,有人能看到问题吗?关键是lasNameFragment是姓氏的片段,我搜索在姓氏中有这个片段的用户.没有LIKE的列表用户工作正常,所以问题必须在这两行中的某个地方.
preparedStatement = connection.prepareStatement("SELECT users.id AS id, login, name, lastname, password, sex, birth, info WHERE lastname LIKE ?;");
preparedStatement.setString(1, "%" + lastNameFragment + "%");
Run Code Online (Sandbox Code Playgroud)
错误:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE lastname LIKE '%Mot%'' at line 1
Run Code Online (Sandbox Code Playgroud)
Mot是lastnamefragment的值,我得到表单搜索输入.
如何在C#中对升序的字符串数组进行排序,我想在C ++中使用类似std :: sort的方法:
std::sort(population.begin(), population.end())
Run Code Online (Sandbox Code Playgroud)
我需要对对象列表进行排序。列表中的对象是Genome类的实例。我在该类中重载了运算符<和operator >。
class Genome
{
public List<double> weights;
public double fitness;
public Genome()
{
fitness = 0.0;
weights = new List<double>();
}
public Genome(List<double> weights, double fitness) {
this.weights = weights;
this.fitness = fitness;
}
public static bool operator <(Genome lhs, Genome rhs)
{
return (lhs.fitness < rhs.fitness);
}
public static bool operator >(Genome lhs, Genome rhs) {
return (lhs.fitness > rhs.fitness);
}
}
Run Code Online (Sandbox Code Playgroud)
这是声明人口的方式:
List<Genome> population = new List<Genome>();
Run Code Online (Sandbox Code Playgroud)
我如何排序此数组?可以像C …
在PC(程序计数器)寄存器发生变化的所有可能性中,我发现了这些:
1) PC increases its value with loading new instruction
2) with jumps and branches
3) with calling subroutine
4) with return from subroutine
Run Code Online (Sandbox Code Playgroud)
这些都是我遗失的东西吗?
我来自这篇文章.
我在C#中使用Windows窗体.我该如何使用saveFileDialog?我有图片框,在图片框上有一个图像,我想保存它.加载的图像是bmp.我想将它保存为4种格式之一:bmp,jpeg,png,tiff.我读了一些关于MDSN的一些注意事项并尝试过但我可能做错了.所以我最好问一下应该怎么写?应该如何编写方法 private void saveFileDialog1_FileOk(object sender,CancelEventArgs e)以及应该如何看待属性saveFileDialog.Filter?谢谢
编辑:
我尝试过:
使用savefiledialog保存图像时发出问题
编辑2:
我试过这个过滤器
Filter = bmp (*.bmp)|*.bmp|jpeg (*.jpeg)|*.jpeg|png (*.png)|*.png|tiff (*.tiff)|*.tiff
Run Code Online (Sandbox Code Playgroud) 问题:如何在注册/登录(任何其他)php页面中使用https?伪代码:
is it https?
yes continue
no redirect same page via https
Run Code Online (Sandbox Code Playgroud)
背景: 我想做一个安全的注册和登录表格.我想通过所有步骤来检测我是否错过了什么.2.我想特别询问如何使用https来保护去往服务器的密码.
添加2. HTTPS CONNECTION CHECK用户单击链接到登录/注册页面,我应该这样做:
是HTTPS吗?是=> CONTINUE,NO =>通过HTTPS重定向页面我知道有一些变量或某些东西告诉我它是否是https,但我不知道如何在php5中编写它(这一两行).那么问题是如何做第2点(HTTPS连接CHECK)?