问题
Here is a snippet of some code. Instead of displaying the characters I am checking for, ╠ is displayed.
while (c!= EOF)
{
    c = getc(fp);
    if (c==32 || c==33 || (c>=97 && c<=122) || c==35)
    j++;
    if(j==clns){
    i++;
    j=0;
    mA[i][j]=c;
    }
}
for (i = 0; i < 10; i++) {
    for (j = 0; j < 20; j++) {
        printf("%c", mA[i][j]);
    }
    printf("%c\n", mA[i][j]);
}
Thanks in advance for your help. :)
回答1:
You are only ever writing to mA[i][0]:
if(j==clns){
    i++;
    j=0;
    mA[i][j]=c;
}
so you are printing random garbage that happened to be in the array. Move the assignment out of the if.
来源:https://stackoverflow.com/questions/12905027/displaying-this-symbol-instead-of-desired-characters