Questions tagged [puts]

Anything related to C or C++ standard library, or Ruby functions `puts` (C, Ruby) or `std::puts` (C++). These functions are used to write a null-terminated string (C, C++), or Ruby's `String` class to the standard output stream `stdout`.

Anything related to C or C++ standard library, or Ruby functions puts (defined in <stdio.h> C standard header, or included in core for Ruby) or std::puts (defined in <cstdio> C++ standard header). These functions are used to write a null-terminated string (C, C++), or Ruby's String class to the standard output stream stdout.

See CPPreference.com:

190 questions
1
vote
2 answers

Nobody, never checks the return value of putc, fputc, puts, fputs, putchar (and maybe printf) functions. Why?

$ cd glibc-2.23 $ grep -ErI --include='*.c' '= *f?put([cs]|char)\>' |wc -l 1 $ grep -ErI --include='*.c' '[^= ] *f?put([cs]|char)\>' |wc -l 1764 $ man putc ... RETURN VALUE fputc(), putc() and putchar() return the character written as an…
user7076126
1
vote
0 answers

How to use Cyirllic alphabets in ruby rails in irb in ruby 2.1 version

i am unable to enter cyrillic alphabets in ruby irb. I have installed cyrillizer,translit and try to paste cyrillic alphabets in irb but it doesnt allow me to paste into command prompt
1
vote
2 answers

Why pointer in puts() function isn't work in line 4 of the following code? Though line 1 is working

char poem[80]="Amar sonar bangla"; char rpoem[80]; int main() { char *pA, *pB; pA=poem; puts(pA); /*line 1*/ puts(poem);/*line 2*/ pB=rpoem; while(*pA!='\0') { *pB++=*pA++ ; } …
DR. SABUZ
  • 19
  • 2
1
vote
1 answer

C Strings, Pointers, Puts

I have been studying a code on Programming in C lately. I got stuck here while dealing with two dimensional strings and pointers. Also the functions printf(), putchar(), and puts() are confusing! Please help me out with the following…
Pushp Sra
  • 606
  • 1
  • 6
  • 6
1
vote
0 answers

What does non zero return value of puts() signify

I was looking at puts function in C++ (cstdio) and found that it returns non-zero value in case of success. I tried searching on internet if there is any significance of that non-zero return value but could not find anything. I have also tried…
Harshdeep
  • 5,614
  • 10
  • 37
  • 45
1
vote
2 answers

C - puts() vs. printf() using \b

printf("backspace\b"); Output: backspac puts("backspace\b"); Output: backspace Why is this? Because puts() adds a terminating newline character and \b is therefore without effect?
Andreas
  • 13
  • 5
1
vote
1 answer

Wierd output characters (Chinese characters) when using Ruby to read / write CSV

I'm trying to print the first 5 lines from a set of large (>500MB) csv files into small headers in order to inspect the content more easily. I'm using Ruby code to do this but am getting each line padded out with extra Chinese characters, like…
Assad Ebrahim
  • 6,234
  • 8
  • 42
  • 68
1
vote
2 answers

Speeding up puts operation to file in tcl

I have to puts large amounts of data to a file in TCL, and it takes very long. I tried increasing the buffer capacity from 4KB to 1MB using fconfigure, but noticed no improvement whatsoever. I am not sure if I could flush my buffer at intervals, as…
SulfoCyaNate
  • 396
  • 1
  • 2
  • 19
1
vote
2 answers

Ruby: puts printing stderr of the result of a command

It's not clear to me how "puts" works in Ruby for the output of a command that throws its output to stderr. Look at this code: command="/usr/bin/java -version" result=`#{command}` puts result puts "XX#{result}XX" The result is: java version…
Mario R.
  • 31
  • 2
1
vote
3 answers

what happens if puts() function doesn't encounter null character?

Consider following program. #include int main(void) { char side_a[] = "Side A"; char dont[] = {'W', 'O', 'W', '!' }; char side_b[] = "Side B"; puts(dont); /* dont is not a string */ return 0; } I know that puts()…
Destructor
  • 14,123
  • 11
  • 61
  • 126
1
vote
2 answers

Hashes and puts

How do elegantly rearrange my code so I can get the output {:monosyllabic=>3, :polysyllabic=>4} instead of the other way around? def polysyllabic(dictionary) words = Hash.new(0) dictionary.each do |word| if word.scan(/[aeiou]/).size > 1 …
catcher
  • 31
  • 1
  • 3
1
vote
4 answers

called object is not a function or function pointer in use of ternary

I am constantly receiving: error: called object is not a function or function pointer When using ternary operator like that: puts("\nx: " (0 == 1) ? "y1\n" : "y2\n"); What am I doing wrong?
Imobilis
  • 1,475
  • 8
  • 29
1
vote
2 answers

Create Chan In TCL for specific app

I use an app that has the ability to run TCL the app itself is written in C++ (shorthand 10) I believe that I push it far beyond what it was ever intended to do. As are most programming languages and good tools. This however poses a uniqe issue some…
CK1
  • 472
  • 1
  • 5
  • 16
1
vote
2 answers

Error printing from dynamically allocated pointer array

I am working with dynamic memory allocation and strings. The assignment is to prompt the user for the number of char strings they'll enter (max 80 char each), then have a function get the strings and another function print the strings and character…
iMPose27
  • 35
  • 5
1
vote
1 answer

Ruby logging in realtime

I am trying to log some output to a file in realtime using Ruby. I would like to be able to do a tail -f on the log file and watch the output get written. At the moment the file only gets written to once I stop the ruby script. What I am trying to…
Rj01
  • 93
  • 1
  • 7