Anarion's Profile User Rating: -----

Reputation: 282 Architect
Group:
Author w/DIC++
Active Posts:
1,454 (0.77 per day)
Joined:
16-May 09
Profile Views:
31,941
Last Active:
User is offline May 11 2014 04:37 AM
Currently:
Offline

Previous Fields

Country:
IR
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
1100

Latest Visitors

Icon   Anarion loves music more than ever :)

Posts I've Made

  1. In Topic: How to search for words in text file?

    Posted 16 Dec 2013

    Also, there is something about the way you are performing I/O operations. The way you should do this in C++ by the use of streams is different than the methods you use in C.
    There is a golden tutorial on this matter here, written by Bench which is located here.
    Basically what you need to do is to implement a reading loop in this fashion:
    ifstream file("test.txt");
    string word;
    while(file>>word) { //you could also use getline here
        //do something
    }
    

    Spoiler
  2. In Topic: C++ File Handling!

    Posted 10 Dec 2012

    The problem is a mismatch between the thing you want to do (what you expect your code to do), and the thing it actually does in the following part:
    if (strcmp (name1, first_name) != 0 && strcmp(name2, last_name) != 0) {
    

    What you have written here is that, if neither the first name nor the last name is equal to what you want to delete, you write this record to the temporary second file (which means you don't want to delete this record, which is correct). But, what if one of the first_name or last_name are equal to the corresponding value to be deleted? Just as you have stated, your code considers these kind of records to be deleted as well, which is wrong.

    Let's consider all cases:
    • (name1 == first_name) and also (name2 == last_name) -> This record has to be deleted
    • (name1 != first_name) but (name2 == last_name) -> This record doesn't have to be deleted
    • (name1 == first_name) but (name2 != last_name) -> This record doesn't have to be deleted
    • (name1 != first_name) and also (name2 != last_name) -> This record doesn't have to be deleted

    But your if statement deletes the record in the first three cases, instead of just the first case. So, change it in a way to match the above.
  3. In Topic: C++ File Handling!

    Posted 10 Dec 2012

    Take a look at this part of your code:
    if (strcmp (name1, first_name) != 0 && strcmp(name2, last_name) != 0) {
        //rest of the code
    }
    

    Ok, let's go step by step. strcmp returns 0 if both strings are equal. Now tell me, what is being checked here? And also, what you wanted to do. Explain these and you can spot the problem :)
  4. In Topic: C++ File Handling!

    Posted 10 Dec 2012

    eof in C++ streams does not mean the same as eof in C. I suggest you read This Tutorial first to understand this problem and the workarounds.

    Basically, you should substitute char arrays with strings and use file1 >> name1 >> name2 >> address >> cell_Number >> land_line for both input operation and also condition checking.
  5. In Topic: Find()Method problem

    Posted 6 Dec 2012

    Good job! Now you are using the returned value of find.

    Also, you could use the remove function defined in <algorithm> and combine it with string::erase to do the same task:
    name.erase(remove(name.begin(), name.end(), '#'), name.end());
    


    What remove does is moving all the '#'s (the element you want to delete from the container) to the end. It returns the location from which these un-needed elements begin. So, you can use erase to delete elements from this position till the end of the container.

My Information

Member Title:
The Persian Coder
Age:
22 years old
Birthday:
May 17, 1992
Gender:
Interests:
Music Production, Tennis, Programming, KitKat, Cars, Bikes
Full Name:
Kian Nezhadfard
Years Programming:
~4
Programming Languages:
Good At: C++, Linux

Contact Information

E-mail:
Private
Twitter:
http://twitter.com/anarion1191

Comments

Page 1 of 1
  1. Photo

    Hybrid SyntaX Icon

    10 Feb 2014 - 14:02
    sup?
  2. Photo

    estherNamogo Icon

    03 Nov 2013 - 06:33
    Hello
    Nice to meet you write
    me at (esther2namogo@hotmail.com) i will send you my picture OK.
  3. Photo

    jatinjindalj Icon

    06 Sep 2012 - 09:01
    Hey Regarding your code snippet at
    http://www.dreamincode.net/code/snippet4621.htm-->
    Can you please explain:
    why when at line 37 and 38,If I do
    while(q!= NULL) {//Line 37
    q = q->link;
    }
    t = new node;
    t->data = str;
    t->link = NULL;<...
  4. Photo

    Anarion Icon

    07 Aug 2012 - 06:23
    Thanks! I had made it for DIC Signature Contest and put it on my sig since then.
  5. Photo

    AnalyticLunatic Icon

    06 Aug 2012 - 09:05
    Just wanted to drop by and say Sweet Sig. Sometime I need to make one for myself.
  6. Photo

    David W Icon

    07 Jun 2012 - 00:31
    Shalom shalom my Regal Persian Coder Friend
  7. Photo

    Anarion Icon

    16 Mar 2011 - 00:56
    @abrsefid: ba arze sharmandegi, komaki az man sakhte nist. Az beine portha faghat ba USB kar kardam oon ham dar sathe kheili payin. Be shoma pishnahad mikonam baraye javabe soaletun dar internet jostejoo konid :)
  8. Photo

    yogesh201010 Icon

    05 Mar 2011 - 18:41
    hi i am yogesh
    how to connect internet by mob in linux.
    and tell me book for linux learning
    thanks
  9. Photo

    abrsefid Icon

    27 Feb 2011 - 05:23
    salam man donbale 1 code c++ (ubuntu) migardam vase send o receive data ba port serial mishe rahnamaeem konid ?
  10. Photo

    hamishehiran Icon

    10 Aug 2010 - 23:02
    thanks for add! ;) nice to meet you!
  11. Photo

    Anarion Icon

    28 Mar 2010 - 08:27
    Thanks! Happy new year to you too :)
  12. Photo

    saSBH2 Icon

    28 Mar 2010 - 07:03
    Happy New Year :)
Page 1 of 1