fscanf question

SMITHJ at ohstpy.mps.ohio-state.edu SMITHJ at ohstpy.mps.ohio-state.edu
Thu Dec 28 09:50:46 AEST 1989


Sorry if this has come up before but I'm puzzled as to why the following code
doesn't work.  The fprintf works fine but nothing is read in by the fscanf.

Thanx in advance.

#include <stdio>

int main(void)
{
	FILE *stream;
	char outstr1[]="Trying", outstr2[]="Hoping";
	char instr1[30], instr2[30];

	stream = fopen("try2.gbk","w");
	fprintf(stream,"%-30s %-30s",outstr1,outstr2);
	fclose(stream);

	stream = fopen("try2.gbk","r");
	fscanf(stream,"%-30s %-30s",instr1,instr2);
	fclose(stream);
}

--
I knew how the game was going to end when I took Brenda 
	into the filing room but I took her in anyway.	--Al
They have one big advantage over us: 
		*they* know where they're going.	--Batman
Has your family tried 'em, Powdermilk?			--Garrison Keillor

/* Jeffery G. Smith, BS-RHIT (AKA Doc. Insomnia, WMHD-FM)       *
 *    The Ohio State University, Graduate Physics Program       *
 *        3193 Smith Lab, Columbus, OH 43210  (614) 292-5321    *
 *    smithj at ohstpy.mps.ohio-state.edu                          */



More information about the Comp.lang.c mailing list