Ox(簡単な関数)
文字を出力する関数
文字を出力する関数
#include <oxstd.h>
fHello(){
println("Hello!");
}
//
main(){
fHello();
}
出力結果
Hello!
引数のある関数
引数のある関数
#include <oxstd.h>
fTest1(const x){
decl y;
y = x;println("(2) x=",y);
}
fTest2(const adX){
println("(4) x=",adX[0]);
adX[0]=1;
println("(5) x=",adX[0]);
}
main(){
decl x;
x = 0; println("(1) x=",x);
println("Function without using address");
fTest1(x); println("(3) x=",x);
//
println("Function using address");
fTest2(&x);
println("(6) x=",x);
}
出力結果
(1) x=0
Function without using address
(2) x=0
(3) x=0
Function using address
(4) x=0
(5) x=1
(6) x=1
返値のある関数
返値のある関数
#include <oxstd.h>
fSquare(const y){
decl y2;
y2 = y^2;
return y2;
}
main(){
decl x,x2;
x = 2;
x2 = fSquare(x);
println("x=",x,", x^2=",x2);
}
出力結果
x=2, x^2=4