printf Questions
3
Solved
6
Solved
Can someone explain the output of this simple program?
#include <stdio.h>
int main(int argc, char *argv[])
{
char charArray[1024] = "";
char charArrayAgain[1024] = "";
...
Mysia asked 21/9, 2011 at 19:27
9
Solved
For doing string concatenation, I've been doing basic strcpy, strncpy of char* buffers. Then I learned about the snprintf and friends.
Should I stick with my strcpy, strcpy + \0 termination? Or sh...
6
Solved
pixel_data is a vector of char.
When I do printf(" 0x%1x ", pixel_data[0] ) I'm expecting to see 0xf5.
But I get 0xfffffff5 as though I was printing out a 4 byte integer instead of 1 byte.
Why ...
4
Solved
http://play.golang.org/p/joEmjQdMaS
package main
import "fmt"
type SomeStruct struct {
somePointer *somePointer
}
type somePointer struct {
field string
}
func main() {
fmt.Println(SomeStruc...
5
Solved
I was running some benchmarks to find the most efficient way to write a huge array to a file in C++ (more than 1Go in ASCII).
So I compared std::ofstream with fprintf (see the switch I used below)...
4
Solved
How can I print out an array in BASH with a field separator between each value and a newline at the end.
The closest I can get with a single printf is printf '%s|' "${arr1[@]}" where | is the fiel...
27
In C, how can I format a large number from e.g. 1123456789 to 1,123,456,789?
I tried using printf("%'10d\n", 1123456789), but that doesn't work.
Could you advise anything? The simpler the...
Philippines asked 19/9, 2009 at 23:38
3
I have a Printer interface that uses the standard go Printf function signature:
type Printer interface {
Printf(format string, tokens ...interface{})
}
I would like to be able to mock this inte...
4
Solved
I am new to C++17 and to std::string_view.
I learned that they are not null terminated and must be handled with care.
Is this the right way to printf() one?
#include<string_view>
#include<...
Kilpatrick asked 10/6, 2022 at 13:58
2
Solved
I know to print int we can use %d, and string we can use %s
but we can still use %v to print them. So what if I always use %v to print them? What issue will happen if I do this?
Frontlet asked 15/12, 2016 at 8:2
19
Solved
Can I do it with System.out.print?
Pemberton asked 29/3, 2010 at 14:45
10
Solved
I am learning C++. cout is an instance of std::ostream class.
How can I print a formatted string with it?
I can still use printf, but I want to learn a proper C++ method which can take advantage ...
Windbroken asked 27/2, 2013 at 7:7
5
Solved
I have this arduino sketch,
char temperature[10];
float temp = 10.55;
sprintf(temperature,"%f F", temp);
Serial.println(temperature);
temperature prints out as
? F
Any thoughts on how to form...
5
I have three files as below
Test.cpp
void helloworld()
{
disable pf;
pf.Disable();
printf("No statement \n");
}
int main()
{
disable dis;
helloworld();
printf("Hello World");
system("paus...
2
I'm using an Ubuntu 22.04 for some software development, and working with binary data. I recently found this announcement for glibc ver 2.35; it states that ver 2.35 incorporates the binary convers...
Skolnik asked 23/12, 2022 at 9:53
3
Solved
I have a situation where I want to use my printf argument twice.
fmt.Printf("%d %d", i, i)
Is there a way to tell fmt.Printf to just reuse the same i?
fmt.Printf("%d %d", i)
59
I can print with printf as a hex or octal number. Is there a format tag to print as binary, or arbitrary base?
I am running gcc.
printf("%d %x %o\n", 10, 10, 10); //prints "10 A 12\n...
0
I'm just starting to learn C moving from C++, and I was just trying out a ton of variable types. I am using the MingGW-w64 toolset with the GCC compiler. This version supposedly uses UCRT runtime i...
Allomerism asked 12/1, 2024 at 13:8
3
My latest iteration
jinit= !git init && printf "* text=auto\n*.java text\n*.jsp text\n*.css text\n*.html text\n*.js text\n*.xml text\n*.sql text\n*.MF text\n*.tld text\n*.md text\n\n# git ...
8
Solved
Goal: serialize data to JSON.
Issue: i cant know beforehand how many chars long the integer is.
i thought a good way to do this is by using sprintf()
size_t length = sprintf(no_buff, "{data:%d}"...
15
Solved
Does Go's fmt.Printf support outputting a number with the thousands comma?
fmt.Printf("%d", 1000) outputs 1000, what format can I specify to output 1,000 instead?
The docs don't seem to mention c...
Polyadelphous asked 22/10, 2012 at 21:38
18
3
Solved
This is my array:
$ ARRAY=(one two three)
How do I print the array so I have the output like: index i, element[i] using the printf or for loop I use below
1,one
2,two
3,three
Some notes for m...
8
Solved
When I use below code:
#include <stdio.h>
int main(void)
{
printf("%s","Hello world\nHello world");
return 0;
}
it prints as:
Hello world
Hello world
How can I prevent this and pri...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.