如何操作命令行参数? 例如
<小时/>te.f90
program print_
integer :: i
character(len = 32) :: arg
i = 1
Do
call get_command_argument(i, arg)
if ( len_trim(arg) == 0) exit
write(*,*) trim(arg)
write(*,*) trim(arg)**2
i = i + 1
end do
end program print_
<小时/>
te.sh
#!/bin/bash
for (( x = 1; x <=3; x++ ))
do
./te $x
done
我将$x
作为arg
character
传递,但我想将arg
作为数字操作,当我执行./te.sh
时,我得到了Operands of binary numeric operator '**' at (1) are CHARACTER(1)/INTEGER(4)
错误提升<?php
$mysqli = new mysqli("localhost", "user", "password","db");
$tag=$_GET["value"];
$result = $mysqli->query("INSERT INTO tag_tbl (tag_value, status) VALUES ('".$tag."', 1)");
if ($result === false) {
echo "SQL error:".$mysqli->error;
} else {
header("location: https://vas.banglalinksgsm.com/sendSMS/sendSMS?msisdn='xxxxx'&message='".$tag."'&userID=xxxxx&passwd=xxxxxx&sender=WSC");
}
?>
。
该怎么办?
答案 0 :(得分:1)
您需要将字符串(arg)转换为整数。
program print_
integer :: i, iarg
character(len = 32) :: arg
i = 1
Do
call get_command_argument(i, arg)
if ( len_trim(arg) == 0) exit
write(*,*) trim(arg)
read(arg,"(I)") iarg
write(*,*) iarg**2
i = i + 1
end do
end program print_