标题:请问如何删除指定的某一行~我弄了很久的没弄出~
只看楼主
炫火
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-6-17
 问题点数:0 回复次数:1 
请问如何删除指定的某一行~我弄了很久的没弄出~
我这是一个书籍管理的程序,现在我想输入某书号,然后删除该书的信息,但我这程序运行完之后并没有删除信息,请高手帮忙看看。               

                fdat.seekg(0,ios::beg);
                book *a ;
                int n , i , bh ,flag = 0;
                cout<<"需要删除的书号\n";
                cin>>bh;
                fdat.seekg( 0, ios::end );
                long posend = fdat.tellg( );
                n = posend/sizeof(book);
                a = new book [n];
                fdat.seekg( 0, ios::beg);
                i = 0;
                do
                {
                    fdat.read( (char *) & a[i], sizeof(book));
                    i++;
        
                    
                }
                while (  posend!=fdat.tellp() );
                i=0;
                do
                {
                    if( a[i].num == bh)
                    {    cout << "该记录为:" << endl ;
                        cout << "编号:" << a[i].num << endl;
                        cout << "书名:"<< a[i].name << endl ;
                        cout << "出版社:" << a[i].publish << endl ;
                        cout << "作者:"<< a[i].author << endl ;
                        cout << "价格:" << a[i].price << endl ;
                        flag=1;

                        goto L;
                        
                        
                    }
                     fdat.write((char*)&a[i],sizeof(book));
                    L: i++;
                } while (i != n );

                fdat.close();
                fdat.open ( fileDat , ios::binary | ios::in | ios::out ) ;
                delete []a;
                break;
搜索更多相关主题的帖子: long 
2011-06-17 22:56
炫火
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-6-17
得分:0 
或者可不可以告诉我删除某行的原理~尽量详细点的~谢谢
2011-06-18 15:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-343234-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.179931 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved