Subj : Re: GPF With 4.52 On 2 printf????? To : borland.public.cpp.borlandcpp From : C0FFEEBAD Date : Wed Feb 23 2005 01:20 am Thank you for answering. 32 bit Win on Win98SE. It will compile everything else I wrote fine. "Ed Mulroy [TeamB]" wrote in message news:421949d0$1@newsgroups.borland.com... > 16 bit DOS, 16 bit Windows or 32 bit Windows program? > > Running under which operating system? > > . Ed > > > C0FFEEBAD wrote in message > > news:4219071c@newsgroups.borland.com... > > > > Probably missing something simple here. Using 4.52. Line > > 1 & 2 remarked out, compiles and runs fine. > > Unremarked out and I get a General Protection Fault??? I > > thought possibly embbeded char's, not. I thought > > file corruption, installed 4.52 again. > > > > > > ///////////////////////// > > // Sort By CHR Length // > > //////////////////////// > > > > #include > > #include > > #include > > //===================================================== > > int main() > > { > > int c1,i,t,word1[310],sze; > > FILE *fp1,*fp2; > > char filename1[81],filename2[81]; > > ofstream outf (filename2); > > //------------------------------------------------------------------------- > > (1) //printf("\n -> Sort words by size. <-\n\n"); > > //......................................................................... > > (2) //printf(" Enter # of chr's to be sorted out to a file : "); > > > > cin >> sze; sze++; > > > > printf(" Enter name of file to be sorted : "); > > gets(filename1); > > // Is string empty > > if ((*filename1) == '\0') > > { > > puts("\n *>No file name entered<*\n"); > > return -1; > > } > > // Open for reading binary; "r+b" specifies read mode. > > fp1=fopen(filename1, "r+b"); > > if (!fp1) > > { > > printf("\n -= ERROR: File %s",filename1); > > printf(" not found. =-\n"); > > return -1; > > } > > printf(" Enter a name for sort file : "); > > gets(filename2); > > // Is string empty > > if ((*filename2) == '\0') > > { > > puts("\n *>No file name entered<*\n"); > > return -1; > > } > > // Open for writing binary; "w+b" specifies write mode. > > fp2=fopen(filename2, "w+b"); > > //......................................................................... > > > > do > > { > > > > i=1; > > > > do > > { > > c1 = getc(fp1); > > } > > while (c1 == 32 || c1 == 10 || c1 == 13); > > > > word1[i++]=c1; > > > > while (c1!=32&&c1!=EOF&&c1!=10&&c1!=13)word1[i++]=c1=getc(fp1); > > t=--i;i=1; > > while (i != sze && t == sze)putc(word1[i++],fp2); > > if (t==sze) putc(13,fp2),putc(10,fp2); > > > > } > > > > while (c1 != EOF); > > > > //......................................................................... > > fclose(fp1),(fp2); > > //------------------------------------------------------------------------- > > return 0; > > } > > .