C++ Program to Implement strspn() Function

This is a C++ Program to Implement the strspn() Function. Problem Description The program implements the function strspn() which takes two strings and returns the length of portion of first string consisting of characters only from second string. Problem Solution 1. The program takes two strings. 2. Using for loops, both strings are compared. 3. … Read more

advertisement

C++ Program to Implement strpbrk() Function

This is a C++ Program to Implement strpbrk() Function. Problem Description The program implements the function strpbrk() which takes two strings and returns a pointer if a string is found in another string. Problem Solution 1. The program takes two strings. 2. Using a for loop, the two strings are compared for same characters. 3. … Read more

advertisement

C++ Program to Implement strncmp() Function

This is a C++ Program to Implement strncmp() Function. Problem Description The program implements the function strncmp() which compares first ‘n’ characters of two strings. Problem Solution 1. The program takes two strings. 2. Using a for loop, first n characters of the strings are compared. 3. The result is printed accordingly. 4. Exit. C++ … Read more

advertisement

C++ Program to Count Number of Words in a String

This is a C++ Program to Find the Number of Words in a Given Sentence. Problem Description The program takes a string and counts the number of words in it. Problem Solution 1. The program takes a string. 2. Using a for loop, the number of spaces in the string are counted. 3. The total … Read more

advertisement

C++ Program to Find the Sum of ASCII Value of All Characters in the String

This is a C++ Program to Find the Sum of ASCII Value of all Elements in a String. Problem Description The program takes a string and prints the sum ASCII values of all the characters. Problem Solution 1. The program takes a string. 2. Using a for loop, the ASCII equivalent of each character is … Read more

advertisement

C++ Program to Compare Two Strings

This is a C++ Program to Compare Two Given Strings for Equality. Problem Description The program takes two strings and checks for their equality. Problem Solution 1. The program takes two strings. 2. Using string function, the two strings are compared. 3. The result is printed. 4. Exit. C++ Program/Source code Here is the source … Read more

advertisement

C++ Program to Toggle Cases in a String

This is a C++ Program to Toggle Cases in a String. Problem Description The program takes a string and changes the cases of the string characters. Problem Solution 1. The program takes a string. 2. Using ctype functions, uppercase characters are converted to lowercase and vice versa. 3. If entered string is not alphabetical, program … Read more

advertisement

Reverse a String in C++

What is String Reversal? String reversal in C++ is the process of rearranging the characters of a given string in reverse order, changing the original order from end to start. Example: Original String: “programming” Reversed String: “gnimmargorp” Problem Description Write a C++ program that takes a string and reverses it. Problem Solution 1. The program … Read more

advertisement

C++ Program to Implement strncpy() Function

This is a C++ Program to Implement strncpy() Function. Problem Description The program takes a string and copies first ‘n’ characters into another string using the function strncpy(). Problem Solution 1. The program takes a string. 2. The number of characters to copied is taken. 3. Using the string function strcpy(), first n characters are … Read more

advertisement

C++ Program to Count the Number of Vowels/Consonants/Numbers/Special Characters in a String

This is is a C++ Program to Count the Number of Vowels/Consonants/Numbers/Special Characters in a String. Problem Description The program takes a string and counts the number of vowels, consonants, numbers and special characters in the string and prints them. Problem Solution 1. The program takes a string. 2. Using if else condition, the string … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.