Hey, I was playing with the Cxx package and tried the following code and got confused.
julia> function playing()
for i=1:5
icxx"""
int tellme;
std::cout << "Please enter a number: " << std::endl;
std::cin >> tellme;
std::cout << "\n Yout number is " << tellme << "\n" << std::endl;
"""
end
end
playing (generic function with 1 method)
julia> playing()
Please enter a number:
f
Yout number is 0
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
julia> function playing()
for i=1:5
icxx"""
int tellme;
std::cout << "Please enter a number: " << std::endl;
std::cin >> tellme;
std::cout << "\n Yout number is " << tellme << "\n" << std::endl;
"""
end
end
playing (generic function with 1 method)
julia> playing()
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
Please enter a number:
Yout number is 0
I did not input number 0 at all. Basically, I only type the letter f, and the julia REPL did not give me any chance to enter any number afterwards…