![]() |
VOOZH | about |
Programming can be complicated, and it's essential to ensure that our code is readable and well-structured. One way to improve code clarity is by using meaningful and descriptive variable and function names. To make every element name unique and more meaningful we use camel case and snake case are two widely used conventions for naming variables and functions. Let us check both of them
Snake case strings begin with lowercase and separate words with underscores where each word start with lowercase.
Example:
event_listener
Camel case strings begin with lowercase and capitalize the first letter of subsequent words
Example:
EventListener
In C++, we can easily convert camel case strings to snake case strings by replacing capital letters with underscores and the lowercase letters that follow them. In this article, we'll delve into how to perform this conversion in C++.
Example:
Camel Case: GeeksForGeeks Snake Case: geeks_for_geeks
Given a string in camel case, the task is to write a C++ program to convert the given string from camel case to snake case and print the modified string.
Example
Input: GeeksForGeeks Output: geeks_for_geeks
The approach to the topic is simple and easy to understand. The approach is mentioned below:
Time Complexity: O(n) Auxiliary Space: O(n)
Implementation of the above topic:
Output
geeks_for_geeks