Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Code working opposite to the language rules.
Post Flair (click to view more posts with a particular flair)
Post Body

Hey dudes! I am amazed by this code today:

void saveContacts(vector<Contact> &contacts)
{
    ofstream contactFile{CONTACT_FILE, ios::out};
    // contactFile.seekp(0, ios::beg);
    if (!contactFile)
        cout << "File couldn't be opened for writing\n";
    else
    {
        for (size_t i = 0; i < contacts.size();   i)
        {
            contactFile << contacts[i].firstName << DELIM;
            contactFile << contacts[i].lastName << DELIM;
            contactFile << contacts[i].phoneNumber << DELIM;
            contactFile << contacts[i].emailAddress << "\n";
        }
    }
    contactFile.close();
}

I am wondering about the file not being overwrritten even though it is opened in out mode. Why does this happen. I am totally happy with this behaviour because that's what I wanted, but that has come unintentionally. What are the possible reasons that this is happening??

// contactFile.seekp(0, ios::beg);

whether the above file is commented out or not, the result is same. Please give me the reason, because I wanted this behavior but not on the mercy of hidden bugs.

Author
Account Strength
60%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
89
Link Karma
72
Comment Karma
17
Profile updated: 4 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 months ago