About 8,190,000 results
Open links in new tab
  1. c++ - How to use printf with std::string - Stack Overflow

    Here's a sampling of a few of the most obvious: As the question shows, printf isn't type-safe. If the type you pass differs from that given in the conversion specifier, printf will try to use whatever it …

  2. What is the difference between printf () and puts () in C?

    Mar 16, 2010 · The function printf () writes output to stdout, under the control of a format string that specifies how subsequent arguments are converted for output. I'll use this opportunity to …

  3. Should I use printf in my C++ code? - Stack Overflow

    Jan 7, 2010 · I generally use cout and cerr to write text to the console. However sometimes I find it easier to use the good old printf statement. I use it when I need to format the output. One …

  4. How to correctly printf strings and characters with %s and %c

    0 The thing is that the printf function needs a pointer as parameter. However a char is a variable that you have directly acces. A string is a pointer on the first char of the string, so you don't …

  5. Should I use %i or %d to print an integer in C using printf()?

    On input, using scanf (), you can use use both %i and %d as well. %i means parse it as an integer in any base (octal, hexadecimal, or decimal, as indicated by a 0 or 0x prefix), while %d means …

  6. How to escape the % (percent) sign in C's printf - Stack Overflow

    Dec 7, 2009 · 7 Nitpick: You don't really escape the % in the string that specifies the format for the printf() (and scanf()) family of functions. The %, in the printf() (and scanf()) family of functions, …

  7. 'printf' vs. 'cout' in C++ - Stack Overflow

    May 20, 2010 · You automatically get to use the zillions of lines of I/O code written by users you don't even know, and they don't need to know about your "extended stream" class. On the …

  8. How to print a float with 2 decimal places in Java?

    System.out.printf("%.2f", val); In short, the %.2f syntax tells Java to return your variable (val) with 2 decimal places (.2) in decimal representation of a floating-point number (f) from the start of …

  9. c - Left-pad printf with spaces - Stack Overflow

    How can I pad a string with spaces on the left when using printf? For example, I want to print "Hello" with 40 spaces preceding it. Also, the string I want to print consists of multiple lines. D...

  10. What is printf/scanf in C++? And why do does it work similarly to …

    Nov 2, 2023 · 1 not a question about a particular code, but in C++ the operators scanf/printf using <stdio.h> seem the same to me as cout or cin in the header <iostream> so can anyone just …