我正在为某个功能而苦苦挣扎。 目标是检查(已清除)用户输入并采取相应措施。
函数如下:
bool checkMove(board *Minesweeper,char *input){
char *tmp;
switch(input[0]){
case '?':
if(isalpha(input[1])){
input[1]=toupper(input[1]);
long eval = strtol(input, &tmp, 10);
if(tmp==input){
printf("something went wrong :(\n");
}
printf("Number: %ld\n",eval);
if (eval>Minesweeper->height) {
printf("Out of Bounds!\n");
} else {
printf("Valid move\n");
}
// other stuff
输出:
Your Move: ?A21
something went wrong :(
Number: 0
Valid move
我正在传递输入值,因此它不是局部函数。相同的代码(strtol)可以在不同的上下文中正常工作。 我认为这与局部变量无关。
答案 0 :(得分:3)
来自man pages:
“ private void formWindowStateChanged(java.awt.event.WindowEvent evt) {
System.out.println(this.getState());
if(this.getState()==1){//this means minimized
System.out.println("Está minimizado");
} else if(this.getState()==0){//this means maximized/normal state
System.out.println("Está maximizado");
}
}
函数将转换字符串的起始部分...”
您的字符串以“ strtol()
”开头,因此该函数失败。一种解决方案是改为执行以下操作:
?A
通过这种方式,您可以“跳过” long eval = strtol(input+2, &tmp, 10);
中的前两个char
。
答案 1 :(得分:0)
很多人建议,要开始数字转换,请从/v1/customers
开始。
{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "No such token: {{ token }}",
"param": "source",
"type": "invalid_request_error"
}
}
谨慎代码会首先检查严格条件长度至少为2。
2019-12-21T18:14:52.154021+00:00: at=info method=POST path="/manage/billing/" host=app.com
2019-12-21T18:14:52.134957+00:00: [4] [INFO] pathname=/app/python/lib/python3.6/site-packages/stripe/util.py lineno=63 funcname=log_info message='Stripe API response' path=https://api.stripe.com/v1/customers/cus_foo response_code=404
2019-12-21T18:14:52.136422+00:00: [4] [INFO] pathname=/app/python/lib/python3.6/site-packages/stripe/util.py lineno=63 funcname=log_info error_code=resource_missing error_message='No such customer: cus_foo' error_param=id error_type=invalid_request_error message='Stripe API error received'
2019-12-21T18:14:52.136791+00:00: [4] [ERROR] pathname=./management/views.py lineno=1755 funcname=admin_billing Stripe error: Request req_bar: No such customer: cus_foo
2019-12-21T18:14:52.153639+00:00: [4] [INFO] pathname=/app/python/lib/python3.6/site-packages/uvicorn/protocols/http/httptools_impl.py lineno=443 funcname=send ('10.45.113.223', 12377) - "POST /manage/billing/ HTTP/1.1" 302
以后的转换检查也需要修改
input + 2