About 244 results
Open links in new tab
  1. Is it possible to modify a string of char in C? - Stack Overflow

    Jan 8, 2014 · You need to copy the string into another, not read-only memory buffer and modify it there. Use strncpy() for copying the string, strlen() for detecting string length, malloc() and free() for dynamically allocating a buffer for the new string.

  2. Replace individual character element of a string C

    Feb 5, 2012 · What you can do is initialize an array with the elements of a string literal. the elements of string1 array are modifiable. When running the code, the string literal will be in a section that is read-only. OS does not allow the code to …

  3. c - Modifying string literal passed in as a function - Stack Overflow

    Feb 21, 2013 · use strcpy/memcpy to bing a local array variable to an outer string literal. See similar questions with these tags. If I have a function in program int main () { char *name = "New Holland"; modify (name); printf ("%s\n",name); } that calls this function void modify (char *s) { char new_name [10] = "Aust...

  4. Strings in C - GeeksforGeeks

    Apr 24, 2025 · In C, reading a string from the user can be done using different functions, and depending on the use case, one method might be chosen over another. Below, the common methods of reading strings in C will be discussed, including how to handle whitespace, and concepts will be clarified to better understand how string input works.

  5. C Strings - W3Schools

    Modify Strings. To change the value of a specific character in a string, refer to the index number, and use single quotes:

  6. Strings in C Language – Create, Access, and Modify Strings

    We have looked at the Strings in C programming language and how to declare, Initialize and modify strings with example programs. We also learned about how to read and print the strings in C programming and finally, we looked at how to pass strings to the functions.

  7. Replace All Occurrences of a Character in a String in C

    Mar 24, 2021 · Enter a string at run time and read a character to replace at console. Then, finally read a new character that has to be placed in place of an old character where ever it occurs inside the string. Following is the C program to replace all occurrence of a character −. Live Demo. char string[100], ch1, ch2; int i; printf("enter a string : ");

  8. Strings in CString manipulation in C - EmbeTronicX

    How to modify the strings in C programming? To change a specific character in a string, use the index number where you want to change and add the character with single quotes. char str[] = "Kite"; str[0] = 'B'; printf("%s", str); // Outputs Bite instead of Kite

  9. C String Functions: Replace and Replace All - Coder Scratchpad

    Apr 29, 2024 · These functions empower developers to dynamically modify strings, opening the door to a wide range of possibilities in text processing. Whether you need to replace a single occurrence or all occurrences of a substring, these functions are essential additions to your programming toolkit.

  10. How do you modify a string in C - Stack Overflow

    Nov 3, 2019 · Here is a demonstration program that shows how the function can be declared and defined.

Refresh