I have written the piece of code below.
And in this file is the output from my program:Code:#include <stdio.h> #include <string.h> #include <stdlib.h> main(){ // open the file FILE*fp; int letter; if((fp=fopen("BMPHTM2.HTM","r"))==NULL) { puts("Cannot open the file"); } //declarations int i=0; char z[2000]; int j; int k; char a[100]; char b[100]; char c[100]; char d[100]; char e[100]; char f[100]; char g[100]; //read each char from file while((letter=fgetc(fp)) !=EOF) { printf("%c",letter); z[i] = letter; i++; } fclose(fp); //full range is j=158 to j<444 (41 per line?) k=0; for (j=158; j<199; j++){ a[k]=z[j]; k++; } k=0; for (j=200; j<240; j++){ b[k]=z[j]; k++; } k=0; for (j=241; j<281; j++){ c[k]=z[j]; k++; } k=0; for (j=282; j<322; j++){ d[k]=z[j]; k++; } k=0; for (j=323; j<363; j++){ e[k]=z[j]; k++; } k=0; for (j=364; j<404; j++){ f[k]=z[j]; k++; } k=0; for (j=405; j<444; j++){ g[k]=z[j]; k++; } printf("%s", z); printf("%s", a); printf("%s", b); printf("%s", c); printf("%s", d); printf("%s", e); printf("%s", f); printf("%s", g); return 0; }
http://cboard.cprogramming.com/attac...tid=5160&stc=1
As you can see I am getting phantom Unicode characters which are distorting the final output.
What is causing these random characters to be inserted, and how do I stop this from happening?
Thankyou for any help.