So I'm trying to create a loop so it would check all the characters in a string array, but I cant quite execute the while loop so well, I'm thinking it keeps on looping. Any suggestions? Thanks for reading.
int i=0;
char string[50];
cout<<"Please enter your name"<<endl;
cin.getline(string,50,'\n');
char ch=string[i];
while(ch!='\0') //I'm not sure if this statement is correct
ch=string[i++];
because I entered a cout statement into the while to check if the loop is running, and it doesn't stop looping. I'm really trying to enqueue the characters into a linked list, but I cant quite get this while loop to work yet.
I'm trying to create a linked list; so far my code is:
node *newnode=new node;
newnode->item=dataItem;
newnode->next=back;
back=newnode;
//front and back are =NULL;
so far it works, but I'm not sure how to set front to be the first node.
I've tried, but it prints the first node twice:
if(isEmpty())
{
front=newnode;
back=newnode;
newnode->next=NULL;
}
else
{
newnode->next=back;
back=newnode;
}
Thanks again for reading, hoping for feedback.