This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with Cygwin reading/storing backspace character


Hi,

I program in C++ and have a problem while reading characters from the
stdin. Cygwin doesn't behave the same way as my Linux do and I don't know
if it's supposed to or not. I've searched the web for several hours but I
can't find any informtion about this so I will be very thankful for some help.

My problem
I use readline to read one line and store the characters in an array. If I
write something wrong and removes it with backspace, both the character
deleted and the backspace character is stored in the array as well. This
does not happen when you use Linux.

My questions
Is Cygwin supposed to behave like this? If so, is there anyway to make it
behave like Linux instead?


Cygwin version: 1.5.11-1
Operating system: Windows XP
Linux version: Linux Mandrake 10.0.

The code I used to test this:
int main()
{
 char text[] = {'A', 'A', 'A', 'A', 'A', 'A', 'A'};

 cin.getline(text, 7);


 //Print the whole string
 cout<<text<<endl;


 //Character by character with a delimiter
 for(int i = 0; i < 7; i++)
 {
   cout<<text[i]<<":";
 }
 cout<<endl;


 //The ascii-values, character by character with a delimiter
 for(int i = 0; i < 7; i++)
 {
   cout<<static_cast<int>(text[i])<<":";
 }
 cout<<endl;
}

If I used the following input:
a
b
remove b with backspace
a
ENTER

I get the following output:
aa                    //Print the whole string
a:b:a: :A:A:          //Character by character with a delimiter
97:98:8:97:0:65:65:   //The ascii-values


If I run the same example in Linux Mandrake 10.0 the result is:
aa                    //Print the whole string
a:a::A:A:A:A:         //Character by character with a delimiter
97:97:0:65:65:65:65:  //The ascii-values


Thank you!
/Maria



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]