Results 1 to 4 of 4

Thread: [SOLVED] Pascal question

  1. #1
    Join Date
    May 2008
    Location
    Chicken Farm
    Beans
    410
    Distro
    Ubuntu 12.04 Precise Pangolin

    [SOLVED] Pascal question

    Hi everbody.
    I have a question.
    I am trying to make a code that will write every character between an character c1 and a character c2. I tried this
    Code:
    Program  whatever (input,output);
    var t,c1,c2:char;
    begin
    read(c1,c2);
    if c1>c2 then 
    		begin
    			t:=c1;
    			c1:=c2;
    			c2:=t;
    		end;
    for t:=c1 to c2 do write(t:2);
    writeln
    end.
    but it gives me this.
    Code:
    a d
       ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a
    How do i change the code to get what i want?
    Thanks.

  2. #2
    Join Date
    Apr 2005
    Location
    Warsaw, Poland
    Beans
    111
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Pascal question (really retarded)

    My Pascal is a little rusty, but my guess would be that the program is reading the "a" and the " " (space) characters, instead of "a" and "d" as you might expect.

    For a quick-and-dirty fix, you might just read the space into some variable:
    Code:
    read(c1,t,c2);

  3. #3
    Join Date
    May 2008
    Location
    Chicken Farm
    Beans
    410
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Pascal question (really retarded)

    Thanks.
    I am used to using spaces for integers and real numbers.

  4. #4
    Join Date
    Apr 2007
    Beans
    14,781

    Re: [SOLVED] Pascal question (really retarded)

    Thread title editted, see: http://stopsayingretard.wordpress.com/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •