About 7,930,000 results
Open links in new tab
  1. string - C++ How to replace number for letter - Stack Overflow

    Dec 11, 2015 · You can do that better with the replace member function of std::string. auto pos = stng.find("1"); // search for 1 in the string if (pos!=stng.npos) // check if 1 is found { …

  2. std::string::replace() in C++ - GeeksforGeeks

    Oct 22, 2024 · In this article, we will learn how to use the string::replace() function in our C++ program. Syntax. The string::replace() function provides 6 different overloads for different …

  3. std::basic_string<CharT,Traits,Allocator>:: replace - Reference

    Aug 8, 2023 · basic_string & replace (const_iterator first, const_iterator last, size_type count2, CharT ch );

  4. string - C++ Users

    Position of the first character to be replaced. If this is greater than the string length, it throws out_of_range. Number of characters to replace (if the string is shorter, as many characters as …

  5. replacing letters with numbers using C++ - Stack Overflow

    char ch = 'g'; // this should be replaced with some kind of an input function. char alp[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; char enc[26] = …

  6. How to Replace a Part of the String in C++ - Delft Stack

    Feb 2, 2024 · This article demonstrates multiple methods of how you can replace a part of the string in C++. replace is the std::string class built-in method and provides the exact feature of …

  7. C++ String Replace Character Made Easy - cppscripts.com

    In C++, you can replace a specific character in a string using the `std::string::replace()` method or by using a simple loop to iterate through the string. Here’s a code snippet demonstrating how …

  8. Replace specific character in a string in C++ - Tutorial Kart

    To replace specific character with another character in a string in C++, we can use std::string::replace() method of the algorithm library. replace() method takes the beginning …

  9. C++ Program to Replace a Character in a String - GeeksforGeeks

    Apr 11, 2023 · Two-Temporary-String Character Replacement. The approach involves iterating over the input string character by character, and replacing the characters as required. For …

  10. How to replace letters in a string with specific integer values?

    Aug 4, 2015 · int i = 0; char long_string[] = "AHDAHDAHDAHDAHDA"; int len = strlen(long_string); for(i = 0; i<len; i++) { if(long_string[i] == 'A') long_string[i] = '0'; else …

  11. Some results have been removed