![]() |
| ||
| HELP me as soon as possible ..! Hi, This program supposed to ask the user to enter the names and the ID numbers and the number of children the employee have, the search shoud work like this taylar 845 3 john 123 2 sara 526 2 **search by name** the user should enter the employee name he's searching for if he entered sara sara 526 2 **search by number of children** if the user enterd 2 john 123 2 sara 526 2 **sort by name** the names sould sorted in alphapatical order john 123 2 sara 526 2 taylar 845 3 ************************************ #include <iostream> |
| ||
| Re: HELP me as soon as possible ..! >the search shoud work like this Okay...and what does it look like? Sorry, but I'm not nearly interested enough in your problem to compile and debug your code to find out what's wrong. You'll have to tell me what your problem is to get help. However, I am interested enough in your problem to play around with my own toy implementation: #include <algorithm>:D |
| ||
| Re: HELP me as soon as possible ..! My problem with searching by employee name, when I enter a name to search for ,I face a debug, also if I entered taylar john sara array s should include: s[0].....taylar s[1].....john s[2].....sara but in my program it is: s[0]....sara s[1]....sara s[2]....sara it always takes the last name entered this is my problem ,if you fix it to me then I can fix the hole program, because my main problem only with searching by employee name . thank you for trying to help me :) |
| ||
| Re: HELP me as soon as possible ..! >it always takes the last name entered That's because you're using a pointer. When you assign name to s[i], s[i] points to name. When the loop is done, all of the pointers still point to name, which contains the last name entered. To fix this, use arrays instead: char s[10][100];>when I enter a name to search for ,I face a debug You mean you get an access violation when you try to write to an uninitialized pointer. You seem to have trouble with pointers, so I would suggest using arrays instead for any project. Leave the pointers for toy programs meant to experiment with features: char j[100]; |
| ||
| Re: HELP me as soon as possible ..! I changed the sort by name like this char s[10][100];<< moderator edit: added [code][/code] tags >> but it doesn't work like what I want, if I entered aaa 111 1 the program should sort them like this aaa 111 1 but it do this aaa 111 1 How can I fix this problem ,plz ?? |
| ||
| Re: HELP me as soon as possible ..! >How can I fix this problem ,plz ?? You fix the problem by taking my advice: Quote:
|
| ||
| Re: HELP me as soon as possible ..! Thay's it, I'm facing problems with the pointers , bcz I learned it just a week before , but I should use pointers ,I have no choice :) |
| ||
| Re: HELP me as soon as possible ..! >but I should use pointers ,I have no choice Well, you still have no choice but to use strcpy if you want to actually swap the strings. Here's a tip. Get it working first, then modify it to suit your requirements. You'll find that using pointers and dynamic memory isn't terribly different than just using arrays. |
| ||
| Re: HELP me as soon as possible ..! well, Thank u very much for trying to help me, I think I have to learn more a bout using pointers :) My be next time I'll be better thanx again :) |
| All times are GMT -4. The time now is 9:40 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC