Bellow is the piece of code that causes Segmentation Fault:

(in Linux Segmentation Fault is usually due to illegal memory access)

else if(intData==3)
                FILE *fp;
                int ch;
                if((fp = fopen("file.txt","rb"))==NULL) {
                    printf("Cannot open Source file.\n");
                while((ch = (int)fgetc( fp )) != EOF) {
                    send(client, (char*)ch, 1,0);
                //send(client, ret, len,0);


Can anybody tell me why is it causing Segmentation Fault??

commented: Stop cross-posting! -7


I've told you about that before in another thread. %s says the next argument is a character array, but all you are passing is a single character. What you should use is "%c", then remove that damned typecast.