9,625 questions
0
votes
0
answers
21
views
ESP32 FFat fprintf garbage in text file
At first I wrote sketch and it worked. File "info.txt" was created correctly.
Then I tried to rewrite the sketch in the style
File file = FFat.open(path); file.print(message) etc.
But when I ...
1
vote
2
answers
96
views
Why does printf fail with "invalid number" within bash script but not at command line? [closed]
I have this function in a bash script:
ver_to_num() {
printf "%03d%03d%03d%03d" $(echo "$1" | tr '.' ' ')
}
ver_to_num 3.18.1.1 works from the command line. But when used in a ...
-2
votes
2
answers
67
views
How to print a list of float64 with justified decimal point in Go
I would like to print a slice of float64 values line by line having all decimal points at the same position in each line. I could print the integer part right justified, the decimal point and then the ...
5
votes
1
answer
259
views
How do I convert a `float` to a `_Float16`, or even initialize a `_Float16`? (And/or print with printf?)
I'm developing a library which uses _Float16s for many of the constants to save space when passing them around. However, just testing, it seems that telling GCC to just "set it to 1" isn't ...
5
votes
2
answers
149
views
Why is the octal "0" prefix displayed despite the explicit 0 precision when printing 0 integer with # flag?
Why is the prefix written with octal when using both the # flag and explicit 0 precision for unsigned int conversions? Is it normal?
I've noticed this and it feels like a bug (I'm not claiming it is).
...
0
votes
1
answer
63
views
How do I use the printf command with a format string beginning with "-"? [duplicate]
I have some items:
items=(one two three)
And I want to print them with leading -, to give this output:
- one
- two
- three
The obvious format string fails:
printf '- %s\n' "${items[@]}"
...
0
votes
4
answers
102
views
Create string based on array values
I am trying to create a tree structure like the tree command.
To keep track of the "heirarchy", I have an array like ("true" "true" "false") or ("true&...
1
vote
1
answer
103
views
Create/append file and write a string from a dialog item, in UTF8
I'm getting text from a dialog item and from a date with:
char input[65536];
char date[11];
GetDlgItemText(hDlg, IDC_INPUTEDIT, input, sizeof(input));
strftime(date, 11, "%Y-%m-%d", tm_info);...
0
votes
1
answer
112
views
confused about printf buffering rule in CUDA global function
The code below always prints out "Hello from the start" before anything else, and "Hello from the end" after anything else, why is that?
Code:
#include <stdio.h>
#include <...
2
votes
2
answers
70
views
Can snprintf format '-0'?
On AVR 8-bit, avoiding floats, I'm dividing a signed integer and formatting it with snprintf:
int16_t tempx10 = -5;
div_t temp = div(tempx10, 10);
char buf[10];
snprintf(buf, sizeof (buf), "%4d.%...
1
vote
1
answer
116
views
printf format specifier %h; is it standard?
Commands
printf 'ABC$def%hx\n' 10 # output: ABC$defa
printf 'ABC$def%s\n' 10 # output: ABC$def10
work as expected.... but I cannot find any info about %h.
Is it available on all systems?
0
votes
0
answers
118
views
The "cout" command does not display the message I want on the screen
I'm using VScode on Windows to program in C++.
The printf command works, but the cout command doesn't work. The compiler doesn't show me an error, either. I've already installed all of the necessary ...
4
votes
7
answers
140
views
Using awk to get PCI Address
I'm working on a one-liner to get the PCI Address of GPUs from Incus. Here is the output of the first part of the command:
incus info --resources | grep -E 'GPU:|GPUs:' -A 20
GPUs:
Card 0:
NUMA ...
3
votes
5
answers
141
views
getting a stream of -1 when I pass EOF in an infinite getchar printf loop
I have just started the K&R book. It introduces a loop using getchar() and putchar() to copy characters from input to output until EOF is reached:
main()
{
int c;
while ((c = getchar()) !=...
1
vote
1
answer
69
views
Printing array with printf vs echo gives different results [duplicate]
I am trying to create an array from a file. In the troubleshooting process, I hope to print out all elements of the array to convince myself I'm doing it correctly. However, when I use a hard coded ...