Category "printf"

Why does snprintf() take a size_t size limit, but returns an int number of chars printed?

The venerable snprintf() function... int snprintf( char *restrict buffer, size_t bufsz, const char *restrict format, ... ); returns the number of characters it

Convert Json string literals to utf8 characters with perl or bash

I have a file full of \u codes and want to replace them all with corresponding utf8 character, for example "\u00FC" will become "ü": Here is how far I got:

Is it safe to use printf("%*s", len, ptr) where len is an integer and ptr is non-null terminated?

Is it safe to use printf("%*s", len, ptr) where len is an integer and ptr is non-null terminated? If not safe, what will happen in the worst case? And then how

C Program, printf() and strlen() argument format for output

Why does my terminal crash when I attempt to run this C Program? Here are the instructions for the programming exercise. #include <stdio.h> #include <

What is faster in PHP: dechex() or sprintf("%x")?

What is the fastest way to convert a number to the hexadecimal representation in PHP: dechex($number) or sprintf("%x",$number)?

Print greek characters in CLion IDE

OS - Windows 8.1 IDE - CLion 2021.3.2 I need to print some greek characters but what I have is these symbols: ╬╗ , ╬╝ , ¤ü

Printing strings and characters as hexadecimal in Go

Why cyrillic strings in hexadecimal format differ from cyrillic chars in hexadecimal format? str := "Э" fmt.Printf("%x\n", str) //result d0ad str :

Strange warning when calling sprintf with .* width specifier

For the following code: https://godbolt.org/z/WcGf9hEs3 #include <stdio.h> int main() { char temp_buffer[8]; double val = 25.3; sprint

What types of error when using the wrong format specifier in printf

Floating-point format specifier is used in printf by the argument has a integer number. What kind of error is it? Is it a run-time error or a syntax error? erro

How does printf("%d",x) work/interpreted?

I am wondering how exactly printf("%d",x) is interpreted. All I know that the compiler reserve a memory to put '%','%d','\0' and returns its address to printf,

C Programming, scanf() function output [closed]

When I run the program on a Cygwin terminal, I am not able to achieve the following output: 38 $92360.88 llama Notepad++ Cygwin Terminal Progr

How to print long double number in xinu?

Function sqrtl doesn't work here, also the printf of long double prints f for all given numbers: #include <conf.h> #include <kernel.h> #include <

How to avoid non-copyable characters in a C application, run by Eclipse

I am working with a C application, which is tested by a Java application, run in Eclipse. The Java application runs the C application, using the standard way: R

Why does printf behave differently when called from a Makefile?

The printf program can be used to print binary data, e.g.: $ printf '%b' '\xff\xff' �� If I put this in a Makefile on its own, it works the same:

Why is ANSI printing the code the first time the function is called and printing colours the second time around?

I am trying to change the colour output of my printf statements in a connect 4 game. I have made a function to set the print colour and reset it. It works for m

How to create 24 bit unsigned integer in C

I am working on an embedded application where RAM is extremely tight. For this purpose I need to create a 24 bit unsigned integer data type. I am doing this us

Remove percentage printf and shell

I'm beginning to learn the shell commands. And I don't know how to remove the percent character in the end. Example: printf poo shows poo% I'm on mac and I us

sprintf-like function for CUDA device-side code?

I could not find anything in internet. Due to the fact that it is possible to use printf in a __device__ function I am wondering if there is a sprintf like func

Why wasn't a specifier for `float` defined in `printf`?

It looks like it could have been, there are (at least in C99) length modifiers that can be applied to int: %hhd, %hd, %ld and %lld mean signed char, short, long

Printing more than one array using print_r or any other function in php

I need to print contents of multiple arrays in my code. Eg function performOp($n, $inputArr, $workArr) { printf("Entered function, value of n