Questions tagged [printf]
printf is a common function for formatted output. C and many other languages have a whole family of related functions. Only use this tag if the question is directly concerned with printf or related functions.
printf
9,559
questions
1
vote
1
answer
65
views
Why does printf flush or not flush depending on where the line is in a loop?
Why, in this program, does the printf function print or not print depending on where it is inside the loop?
#include <stdio.h>
#include <time.h>
int main()
{
char frames[] = {'-',...
0
votes
0
answers
60
views
Why does my printf function not work? Is my while loop not ending? [duplicate]
I am just trying to copy and paste the text input. After which the code must show done.
#include <stdio.h>
/*code to copy all input characters and paste it one by one*/
int main()
{
int c;
...
0
votes
0
answers
80
views
printf causes a segmentation fault when used inside a thread created by clone() [duplicate]
I am trying to use printf inside a thread that is generated by clone(). This is producing a segmentation fault. However, if I instead use std::cout in the same thread, the program runs as expected.
...
1
vote
3
answers
93
views
Does s conversion specifier specify direction / order in which characters are written?
Does s conversion specifier specify direction / order in which characters are written?
N3220 working draft, 7.23.6p8 (emphasis added):
s If no l length modifier is present, the argument shall be a ...
-1
votes
1
answer
65
views
getchar() taking stuff which I print using printf()
#include <stdio.h>
int main() {
int c;
for (int i = 0; i < 10; i++) {
c = (getchar() != EOF);
printf("%d\n", c);
}
printf("As we can see, the value of c is ...
0
votes
0
answers
50
views
printf in assembly NASM x86 print only once of the array in the loop
Calling printf function inside my x86 code, outputs only the first number in the array and stops working even if I remove the call exit. It prints out the first element in the array infinity
extern ...
0
votes
2
answers
100
views
Bash: Conditional formatting against an array with printf
In a bash script, I have some dynamic entries in an array that assemble together at one point for readable output with printf. I'd like to save the cursor at some point while printing through the ...
0
votes
3
answers
114
views
Using the malloc function once initializes all uninitialized variables with a 0
The malloc function is not supposed to initialize any value to any variable it is used on, like the calloc function does. Why then do I keep getting the initialized value of even other varibales to ...
2
votes
3
answers
87
views
how i can print or sum one larger hex in bash
when i use
printf "%064X\n" $((0x1a838b13505b26867))
the number one was truncated
000000000000000000000000000000000000000000000000A838B13505B26867
with big hex/number is worse
printf "...
1
vote
2
answers
66
views
Java print formatting
I need the grid to be aligned in columns the grid stuff includes 1 and 2 number strings but idk how to use print formatting
this is what i have but i want the numbers to be aligned by the right number
...
0
votes
0
answers
20
views
CTF - printf vuln - GOT - can't make it work. GOT @ 0x00404000
I have issues getting my %n exploit in printf vulnerability to work. Any hits ?
Basically, the code calls printf(buf); _exit(0);
I can find _exit with objdump -R
0000000000404018 R_X86_64_JUMP_SLOT ...
0
votes
0
answers
38
views
JavaScript, dynamically decode C style string escape characters E.G. the escape decode part of snprintf()
Based on some user input fields on a webpage, a string primitive is created that contains some C-style escape sequences. E.G. \n \t etc.
What is the proper, safe, way of decoding such a string? In ...
1
vote
1
answer
35
views
Print loop content in an R Markdown report without changing text format
I am preparing a dynamic R Markdown report that requires printing R objects.
First, I define the objects:
{r setup, echo=FALSE}
number <- 25
numbers <- 1:5
And then I print them as follows:
r ...
0
votes
0
answers
36
views
What happens when you missout an argument to the printf function [duplicate]
The following code prints out the Celsius equivalent of Fahrenheit temperatures from 0 to 300 with 20 as step.
#include <stdio.h>
int main(void) {
int fahr, celsius;
int lower, upper, ...
0
votes
1
answer
44
views
Bash Command Substitution in echo/printf doesn't print result on the same line? [duplicate]
Reproducible example
Consider this example:
#!/usr/bin/env bash
echo "[Status] $(killall --wait example)"
Expected output:
[Status] example: no process found
Actual result (being wrong ...