Code:
#include <stdio.h>
main()
{
FILE *fp;
int i, v[10];
for(i=0; i<10 ; i++)
{
printf("Input %dth Number: ",i+1);
scanf("%d", v+i);
}
if((fp = fopen("The_Paradise_Edition.jpeg","wb"))==NULL)
return;
if(fwrite(v,sizeof(int),10,fp)!=10)
fprintf(stderr, "Incomple Input\n");
fclose(fp);
}
This code was written with a .DAT file, but I changed it to a .jpeg file to see what happened.
It is supposed to write user-given integers in the destiny file, but I'm not quite sure what it did to the picture...
What happened was that a copy of the picture, with 40kb instead of the original 1kb was created.
So... what have I done here? If the numbers I wrote have somehow been written in the file, how to I see them?
This reminds me of a winrar trick to hide files in pictures.
EDIT:
Nevermind, I figured it out.
Code:
#include <stdio.h>
#include <stdlib.h>
main()
{
FILE *fp = fopen("The_Paradise_Edition.jpeg","rb");
int ch;
while ((ch=fgetc(fp))!=EOF)
printf("%d",ch);
fclose(fp);
}
I still want to know what am I doing