delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/15/03:45:05

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 15 Oct 2004 09:44:49 +0200
From: "Maria Green" <marigren AT kau DOT se>
To: cygwin AT cygwin DOT com
Subject: Problem with Cygwin reading/storing backspace character
MIME-Version: 1.0
Message-ID: <WorldClient-F200410150944.AA44490090@kau.se>
X-Authenticated-Sender: marigren AT kau DOT se
X-Spam-Processed: kau.se, Fri, 15 Oct 2004 09:44:52 +0200 (not processed: message from valid local sender)
X-MDRemoteIP: 127.0.0.1
X-Return-Path: marigren AT kau DOT se
X-MDaemon-Deliver-To: cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019