Re: print sting using printf in main or functions?
>putc() would output 1 character only, and not really useful or effective in this case.
You must have missed the part where he said "in a loop" and "to display each character one at a time". Of course, the question is a bit ambiguous.
Re: print sting using printf in main or functions?
Yes that's understood. What my point was. that. putc() outputs one character so if you wish to output words to the console, you'll need to LOOP for each character you wish to output. thus being very ineffective.
puts() would eradicate the need for looping altogether.
Re: print sting using printf in main or functions?
Well are you going to design a for loop to loop through and output chars each time? or just call one function to do it. I think we all know which is the most appropriate.
Well are you going to design a for loop to loop through and output chars each time? or just call one function to do it. I think we all know which is the most appropriate.
Re-read the original question -- does not say anything about which method is the most effective or requires the least coding. Actually fwrite() will work as well. I think teachers in college ask silly questions like this one just to see if the student has any imaginagion.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.