There is a possibility with printf, it goes like this:
printf("%.*s", stringLength, pointerToString);
No need to copy anything, no need to modify the original string or buffer.
More Related Contents:
- String manipulation in C (replace & insert characters)
- How do you allow spaces to be entered using scanf?
- Why doesn’t scanf need an ampersand for strings and also works fine in printf (in C)?
- How do I print a non-null-terminated string using printf?
- How to format strings using printf() to get equal length in the output
- printf string, variable length item
- Does C have a string type? [closed]
- ‘ ‘, ‘\n’ , scanf() and output screen
- .NET String.Format() to add commas in thousands place for a number
- How do I concatenate const/literal strings in C?
- How to convert a string to integer in C?
- How do I trim leading/trailing whitespace in a standard way?
- Correct format specifier for double in printf
- Using the equality operator == to compare two strings for equality in C [duplicate]
- printf(“%p”) and casting to (void *)
- Printf variable number of decimals in float
- Case Insensitive String Comparison in C
- Reading a string with spaces with sscanf
- How to control the number of exponent digits after ‘e’ in C printf %e?
- Unsigned values in C
- How to combine two 32-bit integers into one 64-bit integer?
- Centering strings with printf()
- What is the conversion specifier for printf that formats a long?
- How does strcmp() work?
- Why do strings in C need to be null terminated?
- C++: how to get fprintf results as a std::string w/o sprintf
- A possible algorithm for determining whether two strings are anagrams of one another? [closed]
- Turbo C++: Why does printf print expected values, when no variables are passed to it?
- Counting words in a string – c programming
- Is sprintf(buffer, “%s […]”, buffer, […]) safe?