Charred_Phoenix
01-20-2003, 06:55 PM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
int main(void) {
char choice[9];
printf("\t\t\tCharred_Phoenix's Image Zipper\t\t\t\n\n");
choice:
printf("Join or Seperate?");
scanf("%s", choice);
printf("\n");
if(strcmp("join", choice)==0) {
join();
}
else if(strcmp("seperate", choice)==0) {
seperate();
}
else {
printf("Not a valid choice please enter either 'join' or 'seperate'\n");
goto choice;
}
return 0;
}
int join(void) {
FILE *fobo;
char firstfile[255];
char secondfile[255];
char thirdfile[255];
char fourthfile[255];
char fifthfile[255];
char filecon[45472];
char filesource[90000];
char destfile[250];
char gifbuff[100];
int filedes;
int filedes2;
int b_read;
printf("Enter up to 5 source files:");
scanf("%s %s %s %s %s", firstfile, secondfile, thirdfile, fourthfile, fifthfile);
printf("\nEnter destination filename:");
scanf("%s", destfile);
strcat(destfile, ".gif");
fobo = fopen(firstfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcpy(filecon, "\n____________________\n");
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(secondfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(thirdfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(fourthfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(fifthfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
creat(destfile, 0700);
while(b_read > 0) {
filedes = open("bar.gif",O_RDONLY, 0700);
filedes2 = open(destfile, O_WRONLY, 0700);
b_read = read(filedes, gifbuff, 100);
write(filedes2, gifbuff, b_read);
}
write(filedes2, filecon, 45472);
return 0;
}
int seperate(void) {
FILE *fobo;
char file1con[10000];
char file2con[10000];
char file3con[10000];
char file4con[10000];
char file5con[10000];
char filename[255];
printf("Enter image-zip filename:");
scanf("%s", filename);
strcat(filename, ".gif");
fobo = fopen(filename, "r");
fscanf(fobo, "FF\n____________________\n%s\n.................... \n%s\n....................\n%s\n.................. ..\n%s\n....................\n%s\n................ ....\n", file1con, file2con, file3con, file4con, file5con);
fclose(fobo);
fobo = fopen("1", "w");
fprintf(fobo, "%s", file1con);
fclose(fobo);
fobo = fopen("2", "w");
fprintf(fobo, "%s", file2con);
fclose(fobo);
fobo = fopen("3", "w");
fprintf(fobo, "%s", file3con);
fclose(fobo);
fobo = fopen("4", "w");
fprintf(fobo, "%s", file4con);
fclose(fobo);
fobo = fopen("5", "w");
fprintf(fobo, "%s", file5con);
fclose(fobo);
printf("Unzip sucessful");
return 0;
}
This, evil, evil program attempts to print bar.gif's contents to the screen, can anyone tell me why?
Thx
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
int main(void) {
char choice[9];
printf("\t\t\tCharred_Phoenix's Image Zipper\t\t\t\n\n");
choice:
printf("Join or Seperate?");
scanf("%s", choice);
printf("\n");
if(strcmp("join", choice)==0) {
join();
}
else if(strcmp("seperate", choice)==0) {
seperate();
}
else {
printf("Not a valid choice please enter either 'join' or 'seperate'\n");
goto choice;
}
return 0;
}
int join(void) {
FILE *fobo;
char firstfile[255];
char secondfile[255];
char thirdfile[255];
char fourthfile[255];
char fifthfile[255];
char filecon[45472];
char filesource[90000];
char destfile[250];
char gifbuff[100];
int filedes;
int filedes2;
int b_read;
printf("Enter up to 5 source files:");
scanf("%s %s %s %s %s", firstfile, secondfile, thirdfile, fourthfile, fifthfile);
printf("\nEnter destination filename:");
scanf("%s", destfile);
strcat(destfile, ".gif");
fobo = fopen(firstfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcpy(filecon, "\n____________________\n");
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(secondfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(thirdfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(fourthfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
fobo = fopen(fifthfile, "r");
fscanf(fobo, "%s", filesource);
fclose(fobo);
strcat(filecon, filesource);
strcat(filecon, "\n....................\n");
creat(destfile, 0700);
while(b_read > 0) {
filedes = open("bar.gif",O_RDONLY, 0700);
filedes2 = open(destfile, O_WRONLY, 0700);
b_read = read(filedes, gifbuff, 100);
write(filedes2, gifbuff, b_read);
}
write(filedes2, filecon, 45472);
return 0;
}
int seperate(void) {
FILE *fobo;
char file1con[10000];
char file2con[10000];
char file3con[10000];
char file4con[10000];
char file5con[10000];
char filename[255];
printf("Enter image-zip filename:");
scanf("%s", filename);
strcat(filename, ".gif");
fobo = fopen(filename, "r");
fscanf(fobo, "FF\n____________________\n%s\n.................... \n%s\n....................\n%s\n.................. ..\n%s\n....................\n%s\n................ ....\n", file1con, file2con, file3con, file4con, file5con);
fclose(fobo);
fobo = fopen("1", "w");
fprintf(fobo, "%s", file1con);
fclose(fobo);
fobo = fopen("2", "w");
fprintf(fobo, "%s", file2con);
fclose(fobo);
fobo = fopen("3", "w");
fprintf(fobo, "%s", file3con);
fclose(fobo);
fobo = fopen("4", "w");
fprintf(fobo, "%s", file4con);
fclose(fobo);
fobo = fopen("5", "w");
fprintf(fobo, "%s", file5con);
fclose(fobo);
printf("Unzip sucessful");
return 0;
}
This, evil, evil program attempts to print bar.gif's contents to the screen, can anyone tell me why?
Thx