![]() |
|
#1
|
|||
|
|||
About my Sorting with Pointer Notation Program.(Help)!Ok guys im back again because I got an extension till 11:00 pm Wednesday to turn in my program. Ok I finished the program, but I will get 10 points off because I used Array Notations. Im having trouble changing the array notation to pointers so I need some help. Here is my instructions and my completed program is below.
Write a C++ program to solve the following problems. Through out this program assignment you need to use pointer notation. You cannot use array notation. -10 points if you use array notation anywhere in your program except for declaration of your array or reading names form the keyboard. Example of array notation: A[0], A[3][10], A[0][3], etc Example of pointer notation: *A, *(*(A+2)+3), *(*A+2), etc Write a program to prompt the user to enter number of names to be sorted. This number of name has a range from 1 to 20 people. Once you have this number then you need to prompt the user to input names as many number of items as he has specified. These names could be in any order. Your program has to sort them (by firstname) in ASCENDING order. Once you are done, you need to clear screen and print the result. Your first output should be the original set of names (unsorted), then followed by second set of your output (sorted names). At the end of the list, your program has to check whether or not the user wants to quit. If he selects "Q" or "q", then your program should clear the screen and terminate your program. Note: You need to pass your data by using pointer to a function called: o sort_name(char *name [], int *item) o You can clear screen by printing new line character or endl about 20 times. Example: Please enter number of names you want to sort: 4 Please enter 5 items: John Doe Joe More Steven Smith Marry Ann UNSORTED John Doe Joe More Steven Smith Marry Ann SORTED Steven Smith Marry Ann John Doe Joe More Do you want to quit? Q CPP / C++ / C Code:
|
|||
|
#2
|
||||
|
||||
Re: About my Sorting with Pointer Notation Program.(Help)!Hi Cougar,
Why start a new thread when you already have a thread about this assignment? Ok. Here is a start: forget your current code. Take a look at the Dave's post and continue with your old program/ Just two changes and you'll get maximum points: http://www.gidforums.com/t-7680.html Here is a quote from that post: Quote:
Best Regards, ![]() Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#3
|
|||
|
|||
Re: About my Sorting with Pointer Notation Program.(Help)!Ok I will redo my old code instead of the new one that I did. Hopefully it will sort the names like the new code.
peace |
|
#4
|
|||||
|
|||||
Re: About my Sorting with Pointer Notation Program.(Help)!Quote:
The whole idea about pointer notation and array notation is based on the following very fundamental definition in C and C++: If ypt is a pointer to anything and i is an integer data type, then the following two expressions are symantically equivalent. This is fundamental to your understanding of the C language (C++ too) as it is used!!!!!!!!!! (Oops---I just broke the exclamation point key.) Code:
So you can have things like the following: Code:
Furthermore, if yar[] is an array of anything, then if a program uses the name, yar, by itself (with no brackets) it is treated as a constant pointer to the type of data. (And the value of the pointer is fixed as the address of the first element of the array.) So, again, the following two things are equivalent: Code:
Code:
but you can have Code:
A few examples: CPP / C++ / C Code:
In addition to the point about pointers, if I were grading the assignment I would deduct points for every single requirement that was stated. (And I must say, that this is a very clear and complete program specification. I wish all of the things I have ever been given to work on had such a good problem statement. Heck, I wish any of them had.) 1. What about this requirement? Quote:
2. Have you tested your program(s) with the following input names, given as examples in the program assignment? Quote:
3. Remember this requirement: Quote:
4. Don't forget this: Quote:
A final note: in the previous thread I did not intend to imply that I think your sort routine itself is correct. I just wanted to get you to a place where the program would compile so that you can test it. My advice is always this: It's your program. You test it. Don't ever take anything (ideas or code) from anywhere (book, magazine, internet, professional colleague, classmate, or anywhere else --- not even your own past programs that seemed to work) and just assume that it's OK. Test each step before going on to the next. Regards, Dave Last edited by davekw7x : 16-Nov-2005 at 08:50.
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2D arrays:dynamic allocation and freeing | bravetanveer | C Programming Language | 48 | 27-Nov-2007 16:55 |
| Sorting program using pointer notation NEED HELP!! | cougar1112 | C++ Forum | 16 | 14-Nov-2005 12:15 |
| Pointer Usage in C++: Beginner to Advanced | varunhome | C++ Forum | 0 | 19-Aug-2005 10:25 |
| [Tutorial] Pointers in C (Part II) | Stack Overflow | C Programming Language | 0 | 27-Apr-2005 18:36 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The