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
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement