hello
i have a problem in cin characters
this is my code

//file LE.h

struct nodetype;
const int SIZE=81;
typedef char dataline[81];
typedef nodetype *nodeptr;

class LED
{
public:
    LED();
    ~LED();
    void insert(dataline lines);
    void Delete();//delete currnt line 
    void move(int num);
    int cnt();// To Find Number Of Nodes.
    void list();
    void EXIT();



private:
    nodeptr head;
    nodeptr current;

};

//file LE.cpp

#include"LE.h"
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

struct nodetype
{
char data[SIZE];
nodeptr link;
};


LED::LED()
{
head=NULL;
current=NULL;
}
LED::~LED()
{
nodeptr delptr;
while(head!=NULL)
{
delptr=head;
head=head->link;
delete delptr;

}
}

void LED::insert(dataline lines)

{
    nodeptr newptr=new nodetype;
        newptr->link=NULL;

    for(int i=0;i<SIZE;i++)
        newptr->data[i]=lines[i];

    if(current != NULL)

{ 
    nodeptr ptr=head;
    while(ptr->link!=current)
    ptr=ptr->link;
    newptr->link=ptr->link;
    ptr->link=newptr;


}


    else if(head==NULL)
    {
        head=newptr;        
    }
    else
    {
            nodeptr cur = head;
            while( cur->link )
                cur= cur->link;
        cur->link=newptr;
    }




}

void LED::list()
{
    nodeptr put=current;
    if(current==NULL)
        cout<<"<<END>>\n";

    else{
    while(put!=NULL)
    {

        cout<<put->data<<endl;
        put=put->link;
    }
        }
}

int LED::cnt()
{
nodeptr temp=head;
int c=0;
if(head==NULL)
    return 0;
else
    c++;
while(temp->link!=NULL)
{
c++;
temp=temp->link;

}
return c;


}
void LED::move(int num)
{   nodeptr ptrMove;
    //current=NULL;
    ptrMove=head;
    int mMove;

    int funX;


    if(num<0)
    {

    funX=cnt()+num+1;//just for minus

    mMove=abs(num);//for minus

    if(mMove>cnt())
    {
        current=head;
        cout<<current->data<<endl;
    }
    else if(mMove<=cnt())

    {

        for(int i=1;i<funX;i++)
        {
            ptrMove=ptrMove->link;
        }
        current=ptrMove;
        cout<<current->data<<endl;

    }

    }


    else if(num>cnt())
    {
    current=NULL;
    cout<<"<<END>>  "<<endl;
    }
    else 
    {

        if (current==NULL)
            cout<<"<<END>>"<<endl;
        else
        {
        current=current->link;
        cout<<current->data<<endl;
        }
    }

}

void LED::EXIT()
{
exit(1);
}

void LED::Delete()
{
nodeptr Delt;
if(current==head)
{
    head=head->link;
}
Delt=current;
current=current->link;
delete Delt;
}



//client file


#include<iostream>
#include<cstdlib>
#include<cstddef>
#include"LE.h"
#include<string>
#include<cmath>

using namespace std;
int main()
{
    cout<<"###############################################################################\n";
    cout<<"#  Line Editor \n";
    cout<<"#  Please Use these commands (IN,DL,MV,LI,EX). \n";
    cout<<"#  command (IN) To Insert A New Line,should be followed by tow slashes (//). \n";
    cout<<"#  Command (LA) To list All Lines.\n";
    cout<<"#  Command (MV) Should Be Followed By Integer In The Same Line.\n";
    cout<<"#  Command (DL) To Delete The Current Line.\n";
    cout<<"#  Command (XT) To Terminate The Program.\n";
    cout<<"###############################################################################\n";
LED l1; 
int movment;
string input;
dataline line;

cout<<">";
cin>>input;

while(input!="XT")
{

    if (input=="IN")
    {
        cin.getline(line,SIZE);
        while(line[0]!='/'&&line[1]!='/'&&line[3]!='\0')
        {
            l1.insert(line);
        cin.getline(line,SIZE);
        }

    }
    else if(input=="LA")
        l1.list();
    else if(input=="DL")
        l1.Delete();
    else if(input=="MV")
    {   cin>>movment;
        l1.move(movment);
    }
    else if(input=="XT")
        l1.EXIT();
    else
        cout<<"Error Command...!"<<endl;
    cout<<">";
    cin>>input;

}
cout<<l1.cnt()<<endl;


system("pause");
return 0;
}
/*


HERE is my truble


cin.getline(line,SIZE);
            while(line[0]!='/'&&line[1]!='/'&&line[3]!='\0')
            {
                l1.insert(line);
            cin.getline(line,SIZE);

when i trying to input lines
like :
IN
111 1111 1111 111
2222 2222 2222 222
//

should insert into the linked list these lines
111 1111 1111 111
2222 2222 2222 222
just
but it add the // as a line

how i can exclude two slashes??

maybe there is a space after the second / in the last line. Leave off looking for '\0' and just check the first two characters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.