-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Created term entry for .assign() method for C++ strings #7108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @em07-adoz, looks like the entry is jumbled up. The syntax section is apperaing in all the examples. Could you structure it please, then we can continue reviewing the entry. Can you also please fix the path of the file?
Thank you! 😄
Title: '.assign()' | ||
Description: 'Replaces the contents of a C++ string with new characters or strings.' | ||
Subjects: | ||
- 'Code Foundations' | ||
- 'Computer Science' | ||
Tags: | ||
- 'Characters' | ||
- 'Assignment' | ||
- 'Methods' | ||
- 'Strings' | ||
CatalogContent: | ||
- 'learn-c++' | ||
- 'paths/computer-science' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title: '.assign()' | |
Description: 'Replaces the contents of a C++ string with new characters or strings.' | |
Subjects: | |
- 'Code Foundations' | |
- 'Computer Science' | |
Tags: | |
- 'Characters' | |
- 'Assignment' | |
- 'Methods' | |
- 'Strings' | |
CatalogContent: | |
- 'learn-c++' | |
- 'paths/computer-science' | |
Title: '.assign()' | |
Description: 'Assigns new content to a string, replacing its current contents with specified characters, substrings, or values.' | |
Subjects: | |
- 'Code Foundations' | |
- 'Computer Science' | |
Tags: | |
- 'Assignment' | |
- 'Characters' | |
- 'Methods' | |
- 'Strings' | |
CatalogContent: | |
- 'learn-c-plus-plus' | |
- 'paths/computer-science' |
**`.assign()`** is a method used to **replace the contents of a C++ string** with new data. Unlike `.append()`, which adds to the end of a string, `.assign()` **overwrites** the current content. | ||
|
||
This method is useful when: | ||
- You want to fully replace a string with a different one. | ||
- You need to copy a **substring**, specific **number of characters**, or even **characters from an iterator range**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**`.assign()`** is a method used to **replace the contents of a C++ string** with new data. Unlike `.append()`, which adds to the end of a string, `.assign()` **overwrites** the current content. | |
This method is useful when: | |
- You want to fully replace a string with a different one. | |
- You need to copy a **substring**, specific **number of characters**, or even **characters from an iterator range**. | |
The **`.assign()`** method replaces the contents of a string with new characters, allowing precise control over what the string holds. It is commonly used in scenarios such as loops, input parsing, or reusing string variables to optimize memory and performance. |
- You need to copy a **substring**, specific **number of characters**, or even **characters from an iterator range**. | ||
|
||
--- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please showcase the Syntax of this term along with its parameter description and return value.
Description
I created a term entry for the C++ strings .assign() method. My motivation for doing this was a a part of the my project for the Write Tech Bootcamp that I took to learn Technical Writing .
Issue Solved
Closes #7094 [Term Entry] C++ Strings: assign()
Type of Change
Checklist
main
branch.Issues Solved
section.