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
2
votes
4 answers

How to print a string with embedded nulls so that "(null)" is substituted for '\0'

I have a string I composed using memcpy() that (when expanded) looks like this: char* str = "AAAA\x00\x00\x00...\x11\x11\x11\x11\x00\x00..."; I would like to print every character in the string, and if the character is null, print out "(null)" as a…
user1424104
  • 23
  • 1
  • 3
1
vote
1 answer

missing first character when printing string

# include # include #include void main (void) { int size, i,j; printf("enter no. of employee\n"); scanf("%d", &j); printf("size of employee id\n"); scanf("%d",&size); char *m[j]; for (i=0; i
vatsal
  • 11
  • 6
1
vote
3 answers

Difference bw puts with braces() and without braces

What is the difference bw puts("Odin") and puts "Odin"? Context puts "odin" || true gives different result than puts("odin") || true
koil
  • 41
  • 4
1
vote
2 answers

Code doesn't run when I had one more elsif statement

Can anyone please explain to me why my code doesn't run when I have my second elsif statement in. I'm sure it's something simple but I've been over it a few times, wrote out the code again and still can't work out the bug. It only bugs when line 25…
goatstash
  • 162
  • 8
1
vote
0 answers

About the bottom layer operation of the puts() function

What puts() does in C? What does it do in the buffer, and what happens to its arguments? For example, when puts() is passed a string, does puts() send all the strings to the buffer? If a value in a string is set to a null character, whether the…
yida wu
  • 19
  • 2
1
vote
1 answer

About works of _IO_sputn through _IO_file_jumps in glibc

thank you for read my question. When i debug puts function in glibc, I found something which couldn't understand. // glibc-2.27/libio/ioputs.c int _IO_puts (const char *str) { int result = EOF; size_t len = strlen (str); _IO_acquire_lock…
leesh
  • 121
  • 2
  • 11
1
vote
2 answers

Im trying to make a tic tac toe game in C, but I can't figure out how to make puts() print out a character

So, I've started to try to learn c (I came from python) and one of the things I used to learn python was to try to make tic tac toe in python. For this reason, I thought I might as well try to make tic tac toe in c. So, what i want to get done first…
CarcaPo1
  • 31
  • 4
1
vote
1 answer

Why does C puts appends a newline while fputs doesn't?

The C standard provides two functions, puts and fputs, with puts(s) behaving as fputs(s, stdout) except that it additionally appends a newline: The puts() function shall write the string pointed to by s, followed by a , to the standard…
vitaut
  • 49,672
  • 25
  • 199
  • 336
1
vote
1 answer

How to use gets and puts with linked list using pointers

I've written a linked list program and want to take input with spaces but it's not working.It works fine when I simply use "scanf" with %s but since I want to take input with multiple spaces I tried using "gets" and "puts" I've also tried using…
ansme
  • 413
  • 2
  • 11
1
vote
2 answers

Problem with sscanf reading multiple strings from a input file

So I'm slowly continuing learning C. And now, I have a task, to read data from a file and sort it. File data: House naming 1 30 300 House naming 2 45 450 ....... House naming 10 5 120 So, first value: House naming, can be any naming like Empire…
1
vote
0 answers

Rails pry-byebug not accessed

I am trying to debug my code using the pry-byebug tool, but when I launch "rails console" in my terminal and then call on the class method in which the debugger should come into action, nothing happens. I have installed the gem and did a bundle…
Seb
  • 363
  • 1
  • 18
1
vote
0 answers

Size of a function when call sizeof

I have a function as below: int fun() { puts("hello"); return 10; } int main() { printf("%d",sizeof(fun())); return 0; } I want to ask why when I call sizeof(fun()) it just return size of int. and why puts in func() function don't…
Hồng Phúc
  • 408
  • 3
  • 10
1
vote
1 answer

Ruby wont print variable

I've been trying to work on a fake little pin-cracking script, but somethings wrong and it's making me frustrated. It randomizes 4 numbers and checks them against 4 other numbers, but for some reason, after the numbers are guessed, it won't print…
Pixelz
  • 171
  • 1
  • 2
  • 8
1
vote
1 answer

puts and binding.pry output is not visible in test environment

I use minitest and rake task to run tests. I use standard reporter (this is from test helper): Minitest::Reporters.use!( Minitest::Reporters::DefaultReporter.new(fast_fail: true, slow_count: 3), # show single tests with the spec reporter #…
ciemborowicz
  • 93
  • 1
  • 10
1
vote
1 answer

How do the puts and gets functions work?

main() { char name[20]; printf("enter your name\n"); scanf("%s",name); printf("%s",name); gets(name); puts(name); } input: Sampad Saha Output Sampad Saha Here puts only uses the input taken from gets(). as, if I omit this printf()…
Sampad Saha
  • 59
  • 2
  • 5