in this code im trying to assign a character to each element of the array myarray. I have where the error occurs marked below with the message.
Also how can I make a array resize so that it can automatically resize to the number of characters in a text file? ThanksCode:int main() { FILE *fp; char ch; int i=0; char *myarray[i]; if((fp=fopen("C:/text2.txt", "r")) == NULL) { cout <<"Cannot open"; } ch = getc(fp); while(ch!=EOF) { myarray[i] = ch; //error--"assignment to 'char *' from 'char' lacks a cast. ch = getc(fp); i++; } fp=fopen("C:/text.txt", "w+"); for(i=0;i<100;i++){ fprintf(fp,myarray[i]); } system("pause"); fclose(fp); return 0; }





Reply With Quote