We don't need to print a string character by character like we do with arrays. Although the C language has an intrinsic data type for strings, it does provide an access specifier called "percent s" that can be used to print and read texts directly.
The string can be printed using the printf function's %s format specifier. It will print the string starting at the provided address and ending at the null '0' character. The string's initial address is the string's name. As a result, if we specify string name, the complete string will be printed.
Print a String in C++
Use std::cout and << Operator to Print a String.
Use std::copy Algorithm to Print a String.
Use printf() Function to Print a String.
To print a character, you must first supply the character's value to printf. The value can be referred to as name[0] or *name (because name = &name[0] for an array). To print a string, supply a pointer to the string (in this case, 'name' or '&name[0]') to printf.
A string in C programming is a sequence of characters that ends with the null symbol 0. char c[] = "c string" for example; By default, the compiler appends a null character 0 to the end of a sequence of characters wrapped in double quotation marks.
Learner's Ratings
4.4
Overall Rating
69%
18%
5%
4%
4%
Reviews
B
Biwek Gorai
5
I like this course , thank you for your free courses, your free course many people for helpful.
S
SHAYAQ SHAFI
5
sir please provide pdf
Y
Yash Lohiya
5
I am really thanks to learnvern because they give best lectures without any cost sir please. I am really requesting please give us pdf
S
Sonu Kumar
5
teaching is really very awesome.
If assignment would be in the pdf along with lecture. then it would be more benificial.
A
ashish patil
5
Teaching is very best everything is understanding thank you so much 🙏
Share a personalized message with your friends.