www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/05/10:17:52

From: Liche <liche AT ns DOT tp DOT silkera DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Bug in DJGPP?
Date: Sun, 05 Oct 1997 21:34:06 +0800
Organization: New Silkera Network
Lines: 32
Message-ID: <3437974D.E060AD2A@mail.linkease.com.tw>
NNTP-Posting-Host: ts109.tp.silkera.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I use DJGPP v2.01, with RHIDE 1.4.
When I compile this code:
#include <iostream.h>

short counter()
{
    auto short count;
    count ++;
    cout << count << " ";
    return 0;
}

int main()
{
    short i;
    for (i = 0; i < 10; i ++)
       counter();
    return 0;
}

This is displayed:
1 2 3 4 5 6 7 8 9 10

This happens everytime.  Shouldn't the values returned be random?
If I change auto short count; with auto short count = 20; , however,
this is displayed:
21 22 23 24 25 26 27 28 29 30

Is this a problem with me, DJGPP, or RHIDE?
Thanx


- Raw text -


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