tagged [printf]

How to append strings using sprintf?

How to append strings using sprintf? I am facing a serious issue with `sprintf`. Suppose my code snippet is: Some hundred sprints.... If I do like this, it's getting overwritten. How can I avoid overw...

6 Feb at 20:0

what is the printf in C#

what is the printf in C# I want to know what to use in C# to format my output in my console window I tried to use \t but it did not work I know there is printf in C to format my output check this imag...

Is there a way to specify how many characters of a string to print out using printf()?

Is there a way to specify how many characters of a string to print out using printf()? Is there a way to specify how many characters of a string to print out (similar to decimal places in `int`s)? Wou...

31 Oct at 07:35

How do you allow spaces to be entered using scanf?

How do you allow spaces to be entered using scanf? Using the following code: A user can enter their name but when they enter a name with a space like `Lucas Aardvark`, `scanf()` just cuts off everythi...

17 Jun at 16:39

Avoid trailing zeroes in printf()

Avoid trailing zeroes in printf() I keep stumbling on the format specifiers for the printf() family of functions. What I want is to be able to print a double (or float) with a maximum given number of ...

28 Jan at 20:7

printf format specifiers for uint32_t and size_t

printf format specifiers for uint32_t and size_t I have the following I get the following warning when compiling: When I ran this using splint I got the following: ``` Format argument 1 to printf (%u)...

19 Oct at 04:23

Two decimal places using printf( )

Two decimal places using printf( ) I'm trying to write a number to two decimal places using `printf()` as follows: When I run the program, I get the following output: ``` # ./printf When this number: ...

11 Feb at 15:23

The "backspace" escape character '\b': unexpected behavior?

The "backspace" escape character '\b': unexpected behavior? So I'm finally reading through [K&R](https://en.wikipedia.org/wiki/The_C_Programming_Language), and I learned something within the first few...

How can I print a quotation mark in C?

How can I print a quotation mark in C? In an interview I was asked > Print a quotation mark using the `printf()` function I was overwhelmed. Even in their office there was a computer and they told me ...

3 Nov at 12:43

what do these symbolic strings mean: %02d %01d?

what do these symbolic strings mean: %02d %01d? I'm looking at a code line similar to: I think the symbolic strings refer to the number of numeric characters displayed per hour, minute etc - or someth...

31 Jul at 11:7

Code for printf function in C

Code for printf function in C > [source code of c/c++ functions](https://stackoverflow.com/questions/1127328/source-code-of-c-c-functions) I was wondering where I can find the C code that's used so ...

23 May at 12:2

Unsigned values in C

Unsigned values in C I have the following code: The output is: I can see that a value is interpreted

10 May at 22:3

Printing a char with printf

Printing a char with printf Are both these codes the same Will it print a garbage value? I am confused about this Will this print 0 or garbage value? Because when i do this It prints 4. Why is `sizeof...

26 Mar at 14:13

How do you format an unsigned long long int using printf?

How do you format an unsigned long long int using printf? Output: ``` My number is 8 bytes wide and its value is 285212672l. A norm

Using colors with printf

Using colors with printf When written like this, it outputs text in blue: But I want to have format defined in printf: Now I have tried several options how to add color, with no success: I even tried ...

8 Dec at 13:13

Is there a way to have printf() properly print out an array (of floats, say)?

Is there a way to have printf() properly print out an array (of floats, say)? I believe I have carefully read the entire `printf()` documentation but could not find any way to have it print out, say, ...

9 Dec at 08:12

Align printf output in Java

Align printf output in Java I need to display a list of items with their prices from an array and would like to align the prices. I almost have it working but needs improvements. Below is the code and...

21 Dec at 22:14

Printing leading 0's in C

Printing leading 0's in C I'm trying to find a good way to print leading `0`, such as `01001` for a [ZIP Code](https://en.wikipedia.org/wiki/ZIP_Code). While the number would be stored as `1001`, what...

13 Feb at 16:44

%i or %d to print integer in C using printf()?

%i or %d to print integer in C using printf()? I am just learning C and I have a little knowledge of Objective-C due to dabbling in iOS development, however, in Objective-C I was using `NSLog(@"%i", x...

20 Aug at 03:59

printf just before a delay doesn't work in C

printf just before a delay doesn't work in C Does anyone know why if i put a printf just before a delay it waits until the delay is finished before it prints de message? Code1 with sleep(): Code2 with...

27 Oct at 20:58

Is there a free implementation of printf for .net?

Is there a free implementation of printf for .net? The problems: - - - [http://www.codeproject.com/KB/printing/PrintfImplementationinCS.aspx](http://www.codeproject.com/KB/printing/PrintfImplementatio...

4 Mar at 00:45

printf + uint_64 on Solaris 9?

printf + uint_64 on Solaris 9? I have some c(++) code that uses sprintf to convert a uint_64 to a string. This needs to be portable to both linux and Solaris. On linux we use %ju, but there does not a...

3 Oct at 00:17

How to print multiple variable lines in Java

How to print multiple variable lines in Java I'm trying to print the test data used in webdriver test inside a print line in Java I need to print multiple variables used in a class inside a `system.ou...

25 Mar at 05:34

Decoding printf statements in C (Printf Primer)

Decoding printf statements in C (Printf Primer) I'm working on bringing some old code from 1998 up to the 21st century. One of the first steps in the process is converting the printf statements to [QS...

17 Feb at 00:13

How can one print a size_t variable portably using the printf family?

How can one print a size_t variable portably using the printf family? I have a variable of type `size_t`, and I want to print it using `printf()`. What format specifier do I use to print it portably? ...

25 May at 04:30