www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/29/06:58:50

From: shearer AT pluto DOT njcc DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: possible bug?
Date: Fri, 28 Mar 1997 21:36:12 -0500
Organization: New Jersey Computer Connection, Lawrenceville, NJ
Lines: 47
Message-ID: <333C801C.112D@pluto.njcc.com>
NNTP-Posting-Host: ts2-58.njcc.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This is a multi-part message in MIME format.

--------------4E3873DB632C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

++i
i++

when each of these is used in a loop such as below,
   shouldn't the decision to pre-fix or to post-fix
   affect the output of said loop?

the following, compiled and run under djgpp(gcc272),
with the condition of the for loop being ++i or i++,
seems to result in the same for both cases.

such shouldn't be the case, should it?

--------------4E3873DB632C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="test.c"

#define SNUL '\0'
#include <stdio.h>

main(){
char a[10];
int  i;
FILE *IN=NULL;

if((IN=fopen("test.txt","r"))==NULL)
        {
        printf("\nfile does not exist");
        exit(2);
        }
for (i=0;i<9;++i)
{       a[i]= (char) fgetc(IN);
        printf("%i\t%c\n",i,a[i]);
};
a[i] = SNUL;
printf("%i\t%c\n",i,a[i]);
       }

--------------4E3873DB632C--

- Raw text -


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