need a code for this problem!!!!!urgently!!!!

I need help with an assignment that is due on monday and i dont know how to solve it!!!!!
question is:
One program should perform all the tasks given in the following 3 subproblems.
Therefore there must be one single .cpp file.
1:Read names from a file named “name.txt”, it sorts the names in ascending order
according to the last name (or first name is last names are the same) and print the
sorted names in a file named “sorted_name.txt”. The format of a name is :
FirstName LastName.
2:Read 2 positive integers from a user, it finds if the smaller (in number of digits)
number is present in the larger number and its indices. For example if user enters
54826827 and 82 then number 82 is present in 5482 at index 2 and 5.
3:Read an English sentence from a user and prints all the palindromes present in
the sentence. A palindrome can be other than a word. For example: “pop”, “eye”
and “a man a plan a canal panama”




plzz can some one send me the code for the above problem...i will be really gratefull for any help!!!!!!
Could you share with us the code you write ?
actually im still trying to get a grip on reading data from a file as I have recently taken the course.so i dont know how to tackle it.
http://www.cplusplus.com/doc/tutorial/files/

you look here for the files..
cant u/or sum one else like give me the code fr it an like explain it to me.....an how can i put 3 questions of different type in a single code....????
To be able to assist you
should be the main code.

first entered the site
We have encountered the same situation..
This is not something done to you.


http://www.cplusplus.com/forum/beginner/1/
Last edited on
so just tell me if u were given the same question how wud u hv tackled it...:-)...like an algorithm or sumthing....like wat kind of stuff shud be put.....and why and shud arrays be used ????stuff like that????
just give me hints an stuff!!!!!like how i shud tackle it!!!!
hi,

The first thing that i would code would be the menu for your three different actions.

you probably should use 'cin' and 'cout' to display the menu and get the users choice

I would then move onto the first action which is loading,sorting & saving name list.

To do this i would set up an array of character pointers which you can load the data into

1
2
3
4
5
6
7
8

    char*    names[32];

    for (int i=0;i<32;i++)
    {
          names[i] = new char[64];
    }


wasnt going to show any code at this stage but it was the easiest way to explain.

then using an ifstream I would open the file,
enter a while loop to read your data with the getline method.

Thats enough for the moment

bye
thnx a lot.I will try it by ur method!!!!!!!!I think dat this is regarding the first part...thnx !!!!!!
still cant solve it....need more help!!!!!!!
hi again,

show us what you have got so far, so we can see what needs doing

Shredded
Topic archived. No new replies allowed.