Declared global variable isn't being seen by main.



Can someone tell me why giv_len isn't being seen in this statement
below "printf("Record %d wrong length:%d Should be %d
\n",record,cur_len,giv_len)"

=cut

#include <stdio.h>
#include <stdlib.h>

char delimiter = '\n';
unsigned long long int cur_len = 0L;
int giv_len;
unsigned long int record = 0L;

int main(int argc, char *argv[])
{
char* infile = argv[1];
char* outfile = argv[2];
giv_len = atoi(argv[3]);
printf("giv_len is :%d\n",giv_len);

FILE* i = fopen(infile,"r");
FILE* o = fopen(outfile,"w");
int ch;
while((ch=fgetc(i) ) != EOF) {
++cur_len;

if(ch == delimiter) {
++record;
/*printf("%d\n",cur_len); */
if(cur_len != giv_len) {
printf("Record %d wrong length:%d Should be %d
\n",record,cur_len,giv_len);
fprintf(o,"Record %d wrong length:%d\n",record,cur_len);
}
cur_len=0;
}
}
fclose(i);
fclose(o);


return 0;
}
.



Relevant Pages

  • Re: long checkpoints
    ... cat <<eof> prog.c ... main(argc, argv) ... int argc; ... As an aside, you only have the one temp dbspace, which appears pretty active, create another one or two and add them to DBSPACETEMP in the $ONCONFIG ...
    (comp.databases.informix)
  • Re: code question
    ... int main(int argc, char *argv) ... if == EOF) { ...
    (comp.lang.c)
  • Re: code question
    ... int main(int argc, char *argv) ... if == EOF) { ...
    (comp.lang.c)
  • Re: code question
    ... int main(int argc, char *argv) ... if == EOF) { ...
    (comp.lang.c)
  • Re: toy ciphers
    ... int main(int argc, char **argv) ... int ch, pos; ... while )!= EOF) ...
    (sci.crypt)