Skip to content

Conversation

@em07-adoz
Copy link
Contributor

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

  • Adding a new entry
  • Adding a new entry
  • Editing an existing entry (fixing a typo, bug, issues, etc)
  • Updating the documentation

Checklist

  • [ x] All writings are my own.
  • [ x] My entry follows the Codecademy Docs style guide.
  • [ x] My changes generate no new warnings.
  • [x ] I have performed a self-review of my own writing and code.
  • [ x] I have checked my entry and corrected any misspellings.
  • [ x] I have made corresponding changes to the documentation if needed.
  • [ x] I have confirmed my changes are not being pushed from my forked main branch.
  • [x ] I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • [x ] I have linked any issues that are relevant to this PR in the Issues Solved section.

@mamtawardhani mamtawardhani self-assigned this Jun 15, 2025
@mamtawardhani mamtawardhani added c++ C++ entries new entry New entry or entries status: under review Issue or PR is currently being reviewed labels Jun 15, 2025
Copy link
Collaborator

@mamtawardhani mamtawardhani left a 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! 😄

Comment on lines 2 to 14
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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am so sorry. I will work on it.
Thank you

Comment on lines 17 to 21
**`.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**.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**`.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**.

---

Copy link
Collaborator

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.

@CLAassistant
Copy link

CLAassistant commented Jun 19, 2025

CLA assistant check
All committers have signed the CLA.

em07-adoz and others added 2 commits June 19, 2025 10:50
…epts/strings/terms/assign/assign.md to content/cpp/concepts/strings/terms/assign/assign.md. I also structured the syntax.
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing to Codecademy Docs @em07-adoz 😄
The entry looks good for a second round of review! 🚀

Copy link
Collaborator

@Sriparno08 Sriparno08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entry looks good to be merged, @em07-adoz!

@Sriparno08 Sriparno08 merged commit 7f74af0 into Codecademy:main Jun 28, 2025
7 checks passed
@github-actions
Copy link

👋 @em07-adoz
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 Your contribution(s) can be seen here:

https://www.codecademy.com/resources/docs/cpp/strings/assign

Please note it may take a little while for changes to become visible.
If you're appearing as anonymous and want to be credited, visit the linked accounts page and ensure that your GitHub account is linked.

@Sriparno08 Sriparno08 added status: review 2️⃣ completed and removed status: under review Issue or PR is currently being reviewed labels Jun 28, 2025
@em07-adoz
Copy link
Contributor Author

Thank you. I am looking forward to making another contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Term Entry] C++ Strings: assign()

4 participants