delorie.com/archives/browse.cgi | search |
From: | rafael AT geninfor DOT com (Rafael García) |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Multiplie Redirections in dos. |
Date: | Wed, 03 Jul 2002 18:00:22 GMT |
Organization: | Telefonica Data Espagna |
Lines: | 44 |
Message-ID: | <3d233985.12726555@news.mad.ttd.net> |
References: | <BC9127369D17D511B3FB00D0B79134770A8BFC30 AT snlams200 DOT netherlands DOT ncr DOT com> |
NNTP-Posting-Host: | 80-24-251-44.uc.nombres.ttd.es |
X-Trace: | nsnmrro2-gest.nuria.telefonica-data.net 1025719044 26502 80.24.251.44 (3 Jul 2002 17:57:24 GMT) |
X-Complaints-To: | usenet AT nsnmrro2-gest DOT nuria DOT telefonica-data DOT net |
NNTP-Posting-Date: | Wed, 3 Jul 2002 17:57:24 +0000 (UTC) |
X-Newsreader: | Forte Free Agent 1.21/32.243 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
On Wed, 3 Jul 2002 12:08:22 +0200, "Allsted, Geir" <ga180600 AT exchange DOT Netherlands DOT NCR DOT COM> wrote: >Hi. > >I've encountered a problem, that I'm not sure is related to djgpp or windows >itself. >The problem is when you redirect from stdin to stdout several times. I've >been able to narrow it >down to this: > >Source: > >#include <stdio.h> > >int main() >{ > char textline[1024]; > while(gets(textline)) > { > printf(textline); this has at least three problems: 1) printf will try to use textline as a mask for output parameters, it will break if textline contains '%'. Use printf("%s",textline) instead. 2) this skip new lines, so when you give its output to the same program you get lines larger than 1024 chars. Use printf("%s\n",textline) instead 3) given an input file with large lines your 1024 char vector could be too short. Use fgets() instead. > > } > fflush (stdout); >} >
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |