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

    In the case of printf, that means a string with encoded type information like %d meaning int. If you lie about the type or number, the function has no standard way of knowing, although some compilers …

  2. c++ - Is there a way to specify how many characters of a string to ...

    Here, you specify the length as an int argument to printf (), which treats the '*' in the format as a request to get the length from an argument. You can also use the notation:

  3. 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 have to add the * …

  4. What is the meaning of "%-*.*s" in a printf format string?

    Aug 28, 2021 · As an aside, the format doesn't have to be a string literal; it can be a regular pointer (e.g. char *fmt = "%d"; printf(fmt, 3);). This implies that you can assemble it with sprintf programmatically …

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

    In this case, however, we want to control how printf interprets its format string at run-time. As far as the compiler is concerned, the escape sequence % is undefined, and probably results in a single % …

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

    31 You can use: std::format: based on fmt::format, this is the safest standard API snprintf if you are working with a char* - this can help avoid buffer overflow but not type safe std::stringstream if you …

  7. why _Printf_format_string_ macro doesn't produce any warnings?

    Mar 11, 2019 · In the following snippet the wrong usage of format specifiers inside the MyFormat() call should produce a warning, according to SAL specifications, and for the identical call of printf(), I really ...

  8. JavaScript equivalent to printf/String.Format - Stack Overflow

    Mar 4, 2009 · I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET). My basic requirement is a thousand …

  9. c - How to format strings using printf () to get equal length in the ...

    How to format strings using printf () to get equal length in the output Asked 16 years ago Modified 5 years ago Viewed 216k times

  10. java - printf関数とString.formatメソッドの違い - スタック・オーバー …

    May 16, 2022 · printf 関数と String.format メソッドの出力の際の違いについて質問です。 以下のような小数点の数字を四捨五入して出力するプログラムを作っていますが、コードを書く際に使用した …