194 questions
0
votes
1
answer
176
views
Rails puts() not creating any output
In what I've tried to make the simplest of examples, I don't get any output from a puts() to the Rails console or to the development.log when ranges#ranges is hit. The ranges.html.erb is rendered as ...
-1
votes
3
answers
115
views
Functionality of puts
I am trying to understand how puts function works in standard C. I read that it prints a specified
string to the standard output and appends a newline character to this string. However, I get ...
1
vote
1
answer
528
views
missing first character when printing string
# include <stdio.h>
# include <stdlib.h>
#include <string.h>
void main (void)
{
int size, i,j;
printf("enter no. of employee\n");
scanf("%d", &j);
printf(&...
3
votes
3
answers
310
views
Why does the revised version of the “Hello, world!” program from the book Effective C works using `printf`?
I've embarked on learning to program in C. I've started reading Seacord's Effective C book, and I've got confused already on page 6=D
Earlier in the book, there is this little program which he calls ...
1
vote
3
answers
64
views
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
0
votes
2
answers
75
views
When we take input in a string why size does not matter?
#include<stdio.h>`
int main() {
char b[1];
scanf("%s",b);
puts(b);
// gets(b);
// puts(b);
// gets(b);
// puts(b);
return 0;
}
output:
hello_world
hello_world
I ...
1
vote
2
answers
84
views
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 ...
1
vote
0
answers
48
views
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 ...
7
votes
1
answer
4k
views
difference between fputs and puts in c
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 ...
0
votes
2
answers
334
views
Can I use gets() and puts() of same string in different functions
#include <stdio.h>
#include <string.h>
struct employee
{
char ename[20];
int sal;
};
struct employee accept(struct employee);
void display(struct employee);
void main()
{
...
0
votes
2
answers
91
views
Getting error when using puts to output 2d char array in c when sending array as void pointer
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#define size 5
void *displayName(void *...
1
vote
1
answer
2k
views
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;
...
0
votes
2
answers
967
views
How to display multiple items using puts?
I have written a Travel App with Tour Items and I'm trying to display the order at the end.
When I use puts @order_items I get {"SevendaySurfSportTour"=>2} for two tours.
I would like it ...
0
votes
4
answers
295
views
Pointers in C, I'm so confused
Currently I'm following this pdf on C pointers. The code below was meant as a demonstration but confused me beyond belief. Firstly, my understanding of pointers to arrays is that they are initialized ...
0
votes
1
answer
1k
views
Ruby, `puts` doesn't print anything [duplicate]
I'm new to writing in Ruby and I have this assignment for my Programming Languages class where I have to implement Mergesort into Ruby such that the user can enter an array of their own choice of ...
0
votes
1
answer
143
views
How to "set" and "puts" variable, which name consists of string and another variable?
I' trying to get a value of variable, which name consists of string "a" and iterator "i" (in this short example I skipped for loop). I was trying to do it with concat and append, ...
0
votes
2
answers
384
views
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 ...
0
votes
1
answer
1k
views
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 ...
1
vote
2
answers
835
views
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 ...
0
votes
1
answer
387
views
Ruby- gets issue
I'm currently in the process of learning ruby, and I don't know if I'm doing something wrong or the compiler is, but this code:
puts "Name?"
name = gets
puts "Welcome " + name
Outputs:
#blank line ...
2
votes
6
answers
2k
views
How to print an object element inside an array in ruby
I have to print in shell the description of my error, and I can't access to the element inside an object inside an array and I'm still learning Ruby.
I've tried
rescue => e
puts e.fields[...
2
votes
2
answers
1k
views
Printing elements of array in one line in Ruby
I have got the following Ruby hash:
hash = {
0 => "
===
@@@
@ @
@ @
@ @
@@@
===",
1 => "
=
@
@
@
@
@
="}
I would like to print out some of the values of the hash in one line in the console.
To ...
1
vote
0
answers
72
views
Size of a function when call sizeof [duplicate]
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 ...
0
votes
2
answers
546
views
Using fgets and puts to read and print a file not working
I wrote this piece if code below to read a text file that says:
It was the best of times,
it was the worst of times,
it was the age of wisdom.
When I run my code nothing seems to happen. Is there ...
0
votes
3
answers
86
views
String not getting printed
I have been trying to solve a problem, Everything works fine, except that the required string is not getting printed
#include<stdio.h>
int main()
{
int test,i,number,num1;
char ch;
scanf("%d",&...