解析字符串长用C [英] Parsing string to long in C

查看:134
本文介绍了解析字符串长用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Python编写的一台服务器,并在C中的客户端。

I've written a server in python and the client in C.

蟒蛇服务器发送,即1 1000 \\ N到C客户端。

The python server send i.e. "1 1000\n" to the C client.

这是临危此字符串的C函数应该分析它为两个长整型的。

The C function that recieves this string should parse it into two long int's.

void receive_job() {
 char tmp_buffer[256];
 long start, stop;
 recv(sock, tmp_buffer, 255, 0);
 /*
 here I wonder how I can parse tmp_buffer to set start and stop values.
 */
}

我不是在C很精通,所以我会AP preciate对此评论。

I am not very proficient in C, so I would appreciate a comment on this.

推荐答案

查找的sscanf 手册页 - !但检查返回值

Look up sscanf manual page - but check the return value!

这篇关于解析字符串长用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆