Anarion's Profile
Reputation: 282
Architect
- Group:
- Author w/DIC++
- Active Posts:
- 1,453 (0.97 per day)
- Joined:
- 16-May 09
- Profile Views:
- 26,396
- Last Active:
Jan 18 2013 01:09 PM- 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
-
LeonardoSaud 
03 Apr 2013 - 10:17 -
modi123_1 
25 Feb 2013 - 12:30 -
raghav.nagana... 
11 Feb 2013 - 04:42 -
AKMafia001 
15 Dec 2012 - 09:00 -
Groudon 
02 Dec 2012 - 04:54 -
rnty 
30 Nov 2012 - 03:08 -
aresh 
25 Nov 2012 - 11:36 -
GloomyDawn 
25 Nov 2012 - 04:52 -
darek9576 
12 Nov 2012 - 16:14 -
jatinjindalj 
06 Sep 2012 - 08:57
Posts I've Made
-
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. - (name1 == first_name) and also (name2 == last_name) -> This record has to be deleted
-
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
-
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. -
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. -
In Topic: array of structures task
Posted 6 Dec 2012
I am not sure of what you are asking, if you could state it more clear, it would be better
My Information
- Member Title:
- The Persian Coder
- Age:
- 21 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
Friends
-

NickDMax
-

Bench
-

Martyr2
-

borninlyoko
-

hawkysu
-

David W
-

gabehabe
-

erik.price
-

Dogstopper
-

SixOfEleven
-

Hybrid SyntaX
-

bita
-

n8wxs
-

Martyn.Rae
-

thapchi
-

khalid10
-

sarmanu
-

Bml
-

BetaWar
-

williamgeo...
-

Tapas Bose
-

FrozenSnake
-

kowwok
-

Jokah
-

DaneAU
-

JackOfAllT...
-

saSBH2
-

skyhawk133
-

Choscura
-

alias120
-

Handler
-

Elcric
-

b.mahsa
-

Niles_M
-

hamishehiran
-

Shahrzzad
-

ahamedirsh...
-

PlasticineGuy
-

ishkabible
-

Karel-Lode...
-

rnty
-

raghav.nag...
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
jatinjindalj
06 Sep 2012 - 09:01http://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;<...
Anarion
07 Aug 2012 - 06:23AnalyticLunatic
06 Aug 2012 - 09:05David W
07 Jun 2012 - 00:31Anarion
16 Mar 2011 - 00:56yogesh201010
05 Mar 2011 - 18:41how to connect internet by mob in linux.
and tell me book for linux learning
thanks
abrsefid
27 Feb 2011 - 05:23hamishehiran
10 Aug 2010 - 23:02Anarion
28 Mar 2010 - 08:27saSBH2
28 Mar 2010 - 07:03