puts Questions
4
Solved
I currently have this program that prints a text file on the console, but every line has an extra new line below it.
if the text was
hello
world
it would output
hello
world
the code is this
#...
1
Solved
please explain it to me that what is the dfference between
puts(string name) and fputs(string name,stdout)
both of them have the same output especially when I use fgets(string name,n,stdin) for get...
11
Solved
In a book that I'm reading, it's written that printf with a single argument (without conversion specifiers) is deprecated. It recommends to substitute
printf("Hello World!");
with
puts("Hello W...
Keloid asked 8/7, 2015 at 11:6
1
Solved
Could someone explain to me why in ruby console (version 2.3.4)
trying to print hashes
these work:
puts({a: 'a', b: 'b'})
puts(a: 'a', b: 'b')
puts a: 'a', b: 'b'
puts [a: 'a', b: 'b'] <<<...
Oldwife asked 10/5, 2018 at 19:7
4
Solved
array = Array.new(10) { Array.new(10 , 0)}
array.each { |x| print x }
Prints out one single line of ten [0, 0, 0, 0, 0, 0, 0, 0, 0, 0].
If I were to change print to puts, I then get 100 0 down ...
3
Solved
I am doing a ctf problem and there is a line i can't understand.
int (*fp)(char *)=(int(*)(char *))&puts, i;
Can anyone explain me what does this mean?
2
Solved
I've came across a weird thing doing simple tasks in Ruby. I just want to iterate the alphabet with the each method but the iteration goes first in the execution:
alfawit = ("a".."z")
puts "That's...
3
If everything is an object in Ruby, to the point that even math operators are methods applied to objects, when I write:
puts "Hello world"
The method is puts, and the parameter is "Hello world",...
1
Solved
I'm pretty new to programming and wanted to ask why I get the same result with different code. I'm actually reading a book and the example in the book is with printf (also in Assembler). In t...
Indignity asked 28/12, 2016 at 23:12
10
Solved
I know you can print with printf() and puts(). I can also see that printf() allows you to interpolate variables and do formatting.
Is puts() merely a primitive version of printf(). Should it be us...
3
Solved
I am calling to_s within a method:
$ def my_function(num)
$ number = num.to_s.split(//)
$ puts number
$ end
$ my_function(233)
2
3
3
# => nil
It looks to me like within the function, no arra...
3
Solved
I know this may seem like a really simple question, but it really bothers me that my puts keep generating "=> nil" and I scoured for an answer but could not find one. Thanks.
puts 'blink ' *4
...
2
Solved
I wrote a madlib in Ruby, and want to save the resulting madlib to a txt file. This is what I wrote, but the resulting txt file is empty:
file=File.open("madlib_output.txt","a")
file.puts
file.clo...
1
I'm trying to use "puts" to test a few things with a Sinatra app that's hosted on Heroku. Interestingly, the output seems to queue up and only displays upon restarting the Heroku dyno. I've tried w...
1
Solved
I am not sure if this question is too silly but I haven't found a way to do it.
Usually to puts an array in a loop I do this
current_humans = [.....]
current_humans.each do |characteristic|
puts...
1
Solved
As the title, is there any way to use color texts at expect shell?
Like the shell script echo command below.
echo -e "\033[32m Hello World"
3
Solved
I was wondering the difference between puts() and printf() functions while using sleep() function.
Here is my code(In C language):
printf("hello, world");
sleep(1);
printf("Good, bye!");
After ...
3
Solved
I'm executing an Active Record query in controller. And now I want to view all of its contents weather it is in the form of array or object. I want to see the structure in which the data is being r...
Rothman asked 22/10, 2012 at 12:10
1
© 2022 - 2024 — McMap. All rights reserved.