DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25

Thread: Project Help : Where to Start?

  1. #16
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    For a straight text file, I would go with:

    ID
    Name
    Address

  2. #17
    Join Date
    Jan 2008
    Posts
    37
    Thanks
    Text Style Matter is ok now
    so whats next?

  3. #18
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Write the code to actually add records to your text file.

    Make up names, address and Ids for, say, oh, 15 students. When you have all 15 added, we will move on to either Editing or Search, depending on what you want to do next.

    But first, lets get through the actual coding for the adding part.

  4. #19
    Join Date
    Jan 2008
    Posts
    37
    Thanks, Its 12:40 AM Night
    Ill write the code and post it here tomorrow
    Plz do 1 more favour
    tell me what diz code will perform?
    e.g [code take a variable, then pass it to, and then output it to etc]
    [i know its a stupid question, bt me = newbie :(]

    this code will be executed from ADD Function
    Last edited by manofspirit; 01-11-2008 at 03:44 PM.

  5. #20
    Join Date
    Oct 2007
    Posts
    17
    Hi, I have little comment :
    Why not text file layout be like this :
    id*stdntName|address ? (every coloumn separated with *) .
    this will make reading data from text file easier using fread() ,wont it ?
    for example :
    fread( buffer, sizeof(char),128 , stream ); // Reading line-line from DB file text
    // here buffer will be entir line read from text file, Ok ? then
    using for loop we can loop throw buffer[n] and check if buffer[n] = '*' ,if so then we have get the id from text file , and so on . Is it ok for you ? I hope finding answer from professional poeple here .
    Last edited by Asel; 01-12-2008 at 01:43 AM. Reason: To replcace "id*stdntName*address" with "id*stdntName|address"

  6. #21
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    You would need to display, on screen, a spot for the user to enter the first name, last name, address and student id.

    Then, some type of key entry that will take what has been entered, and write it back to your text file.

    Then, a question "Would you like to add another (Y/N)?" If "Y" then, redo the screen prompts. If "N" end the program.

  7. #22
    Join Date
    Jan 2008
    Posts
    37
    @Asel
    Thanks for your reply too, But as iM not a professional so cant give my view, i think we should ask from HACK to give his views regarding this layout...
    @Hack
    What do you say about Asel`s Text Style?
    I wrote a simple code, Thanks for telling in detail about ADD Function,
    Plz check following code and do corrections



    Code:
    #include<iostream>
    #include<fstream>
    #include<string>
    using namespace std;
    
    void dAdd();
    void dEdit();
    void dDelete();
    void dSearch();
    void dShowALL();
    
    fstream dFile("records.txt", ios::in | ios::out);
    
    int sId;
    string sName, sAddress; 
        
    int main()
    {
        
        
    
        if(!dFile)
        { 
            cout<<"Can't open input file." << endl;
            exit(1);
        }
        
        cout << "1 to Add" << endl;
        cout << "2 to Edit" << endl;
        cout << "3 to Del" << endl;
        cout << "4 to Search" << endl;
        cout << "5 to ShowAll" << endl;
        cout << "Any digit to Exit" << endl;
        
        int choice;
        cin >> choice;
        
        switch(choice)
        {
        case 1:
                dAdd();
                break;
        case 2:
                dEdit();
                break;            
        case 5:
                dShowALL();
                break;            
        default:
                break;
        }
    
        cout << "Thanks for Using Our Program" << endl;
        dFile.close();
        return 0;    
    }    
    
    
    void dAdd()
    {
        cout << "Enter ID, Name and Address" << endl;
        cin >> sId >> sName >> sAddress;
        dFile.seekg(0, ios::end); 
        dFile << endl;
        dFile << sId << endl;
        dFile << sName << endl;
        dFile << sAddress << endl;        
        cout << "Do you want to Write More? y/n" << endl;
        char choice;
        cin >> choice;
        if (choice == 'y')
        {
           dAdd();
         } 
    }  
    
    void dEdit()
    {
        cout << "Edit" << endl;     
    }  
    
    void dDelete()
    {
        cout << "Delete" << endl;     
    }  
    
    void dSearch()
    {
        cout << "Search" << endl;     
    }  
    
    void dShowALL()
    {
        char line[100]; 
        while(!dFile.eof())
        {
        dFile.getline(line,100);
        cout << line << endl;
        }
    
        cout << "\nShowAll" << endl;
    }
    Last edited by manofspirit; 01-12-2008 at 01:01 PM.

  8. #23
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    I just have one question:

    Does what you have done work?

  9. #24
    Join Date
    Jan 2008
    Posts
    37
    yes it works
    Plz check it out on ur system as well
    so what should be the next step?
    Last edited by manofspirit; 01-12-2008 at 07:27 PM.

  10. #25
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Well, before you can edit a record, you have to find it, so I would suggest working on Search next.

    Now, how do you think, based on what you know so far, that you would go about coding a search routine for a text file?

    Tips: You should be able to search for:

    Last Name or Student ID

Similar Threads

  1. Replies: 1
    Last Post: 11-29-2006, 07:59 AM
  2. Update for AgMapthat Project Browser Plus released
    By Todd B - Agendum Software in forum vb.announcements
    Replies: 0
    Last Post: 03-31-2001, 07:12 AM
  3. Replies: 0
    Last Post: 09-13-2000, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center