W
worlman385
why the follow print statement only print the number$C
$C = 15;
print "Number of C is " + $C +"\n";
$C = 15;
print "Number of C is " + $C +"\n";
why the follow print statement only print the number$C
$C = 15;
print "Number of C is " + $C +"\n";
why the follow print statement only print the number$C
$C = 15;
print "Number of C is " + $C +"\n";
why the follow print statement only print the number$C
$C = 15;
print "Number of C is " + $C +"\n";
^^Sherm Pendley said:[...]why the follow print statement only print the number$C
$C = 15;
print "Number of C is " + $C +"\n";
The string concatenation operator is "." (without the quotes), so what
you wanted to do is:
print "Number of C is " . $C . "\n";
[...]
And finally, concatenating a bunch of strings together just to print the
result isn't the most efficient way to do it. You can also pass a series
of arguments to print(), which will print them one after another:
print "Number of C is", $C, "\n";
To be honest though, you'd have to print a few million strings to notice
the difference in most circumstances.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.