From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,18266fa31456a58 X-Google-Attributes: gid103376,public From: dale@cs.rmit.edu.au (Dale Stanbrough) Subject: Re: compare a string variable with a string literal Date: 1998/10/11 Message-ID: #1/1 X-Deja-AN: 399791303 References: X-Complaints-To: abuse@cs.rmit.edu.au X-Trace: emu.cs.rmit.edu.au 908060338 9917 131.170.27.23 (10 Oct 1998 22:58:58 GMT) Organization: RMIT NNTP-Posting-Date: 10 Oct 1998 22:58:58 GMT Newsgroups: comp.lang.ada Date: 1998-10-10T22:58:58+00:00 List-Id: Someone wrote: " How do you compare a string variable with a string literal?? It's not working. Please post and email response if possible." It does work very well. No doubt you are doing... X : string (1..100); Last : Natural; ... Get_Line (X, Last); ... if X = "hello" then... this will of course return false, because a 5 character string cannot equal a 100 character string. Ada strings _do not_ work like C strings - there is no terminating character at the end of the valid input. If you want to store variable length strings then use ada.strings.unbounded... with ada.strings.unbounded; use ada.strings.unbounded; ... X : string (1..100); Last : Natural; Y : unbounded_string; get_line (x, last); y : = to_unbounded_string (X (1..last)); if y = "hello" then this _will_ do what you want it to. Dale