我在Ubuntu 14.04上输入此代码
#include<stdio.h>
int main() {
int i, j, n;
scanf("%",&n);
for (i=0;i<=n;i++){
for (j=0;j<=i;j++){
printf("*");
}
printf("\n");
}
return 0;
}
但它打印的星星太多而且一直持续到关闭它为止。
答案 0 :(得分:2)
应该是:
function getToken() {
if (customerToken) {
return Promise.resolve(customerToken);
} else {
// Asynchronous call to Stripe to get the data that will be stored as customerToken
return Stripe.customers.create({
source: stripeToken,
email: customerEmail,
}).then(function(customer){
// Note: this request() is sent asynchronously and
// this promise does not wait for it's response
// You could make it wait by returning a promise here
// store customerToken on my end
request({
url:'[anAPI]',
method: 'POST',
json: {customerToken: customer}
});
return customer;
});
}
}
getToken().then(function(token) {
// use the token here
});
您忘记告诉scanf您使用%d参数
读取整数答案 1 :(得分:1)
中有错误
的scanf(&#34;%&#34;,&安培; N);
它将是:
的scanf(&#34;%d&#34;,&安培; N);
告诉编译器n的值是整数类型。