C
Chad
my input file is:
test
my program:
#include <stdio.h>
#include <stdlib.h>
#define LOG "/home/miss_xtc/flood/words2.txt"
#define BUFF 20
struct data {
char val[BUFF];
};
int main(void) {
struct data profanity;
FILE *fp;
if ((fp = fopen(LOG,"r")) == NULL){
perror("error in load_data function:");
exit(1);
}
while(fread(&profanity,sizeof(struct data),1,fp) == 1) {
/*fwrite(&profanity,sizeof(struct data),1,fp);*/
}
printf("%s\n", profanity.val);
if(ferror(fp)){
perror("can't read file: ");
}
fclose(fp);
return 0;
}
the output:
miss_xtc@linux:~/flood> gcc -g -Wall beta2.c -o beta2 -lefence
miss_xtc@linux:~/flood> ./beta2
Electric Fence 2.2.0 Copyright (C) 1987-1999 Bruce Perens
<[email protected]>
test??<??@0?
miss_xtc@linux:~/flood>
Chad
test
my program:
#include <stdio.h>
#include <stdlib.h>
#define LOG "/home/miss_xtc/flood/words2.txt"
#define BUFF 20
struct data {
char val[BUFF];
};
int main(void) {
struct data profanity;
FILE *fp;
if ((fp = fopen(LOG,"r")) == NULL){
perror("error in load_data function:");
exit(1);
}
while(fread(&profanity,sizeof(struct data),1,fp) == 1) {
/*fwrite(&profanity,sizeof(struct data),1,fp);*/
}
printf("%s\n", profanity.val);
if(ferror(fp)){
perror("can't read file: ");
}
fclose(fp);
return 0;
}
the output:
miss_xtc@linux:~/flood> gcc -g -Wall beta2.c -o beta2 -lefence
miss_xtc@linux:~/flood> ./beta2
Electric Fence 2.2.0 Copyright (C) 1987-1999 Bruce Perens
<[email protected]>
test??<??@0?
miss_xtc@linux:~/flood>
Chad