About 7,170,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. 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 …

  3. '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 …

  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. 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 …

  6. 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 …

  7. printf - How do I print the percent sign (%) in C? - Stack Overflow

    It would be unlikely for both the \ and the % to make it through to printf, even if printf were prepared to treat the \ specially. So the reason why one must type printf("%%"); to print a …

  8. c++ - Best way to safely printf to a string? - Stack Overflow

    Does anyone know a good safe way to redirect the output of a printf-style function to a string? The obvious ways result in buffer overflows. Something like: string s; output.beginRedirect( s ); //

  9. 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, …

  10. c - How to use printf () in multiple threads - Stack Overflow

    Jan 4, 2022 · Note the use of 'as if'. However, each of the printf() functions is required to apply the lock so that access to a stream is controlled in a multi-threaded application. Only one thread at …