>nice try..but i still think that you suck
I'm sorry that my well informed arguments didn't penetrate your barrier of idiocy.
>the reason i posted that code
That's nice. Next time say so to avoid teaching bad habits. And before you answer, "If you find a better way" doesn't count as a disclaimer that your code bites.
>could you please tell me how a picture is encoded into a .dat (data file) format ?
.dat isn't an image file format.
>and what are the flaws in my code??
Off the top of my head:
>#include
You don't use any math routines, this can be removed.
>#include
Your use of conio functions is limited to poor examples that can be either avoided as stupid, or replaced with a standard function.
>void main( )
This makes your program completely undefined. The proper definition for main is
int main ( void )
or
int main ( int argc, char *argv[] )
if you process command line arguments.
>unsigned char i[100][100;
Syntax error, you forgot a closing square bracket.
>clrscr();
Unnecessary. It only serves to make your code nonportable.
>if((fp = fopen("lenna.dat","r+")) == 0)
There's no need to open this stream as an update stream. All you do is read from it, so the mode should be "r". Hardcoding the filename is also a bad practice. A better solution would be to ask the user for a file to open. Also, on a purely stylistic note, NULL is more descriptive than 0 when testing for a null pointer.
>exit(1);
1 isn't a portable argument for exit. A better choice would be EXIT_FAILURE, defined in stdlib.h.
>fscanf(fp,"%c",&i[m][n]);
That's a lot of work just to get the same effect as
i[m][n] = (unsigned char)fgetc ( fp );
There are also potential issues with mixing char and unsigned char in scanf, not to mention that i is an awful choice of names for your array.
>getch();
This can be replaced with getchar() at only a minor inconvenience to users that care.