1

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. :)

JayDave
  • 115
  • 4
  • 9
  • That 'symbol' cannot fit into a single `char` most likely, as it is unicode. – Richard J. Ross III Oct 15 '12 at 22:42
  • please post full code. do you initialize `mA` ? – Karoly Horvath Oct 15 '12 at 22:42
  • 1
    I haven't seen that character for years!! Used to be one of the characters you used to create text-based windows in DOS, before MS Windows hit the scene. It certainly used to fit in a `char`, as it was part of the Extended ASCII set (128-255). But perhaps it has been moved somewhere else now, since text-windowing is a lost art. – paddy Oct 15 '12 at 22:52
  • Ahh here we go... Anyone who was anyone used to have a printout of [this image](http://www.cdrummond.qc.ca/cegep/informat/professeurs/alain/Images/ascii2.gif) (or similar) on hand at all times. If I type Alt-204 (on the numeric keypad), I still get a `╠`. Looks like the standard is still alive and kicking. – paddy Oct 15 '12 at 23:03
  • 2
    ╠ is 0xCC in codepage 437, and [MSVC fills 0xCC to uninitialized memory to help debugging](https://stackoverflow.com/q/370195/995714). That means you've accessed uninitialized memory. You can find tons of questions about ╠ and 0xCC here on SO – phuclv Aug 18 '18 at 10:53

1 Answers1

5

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.

Daniel Fischer
  • 181,706
  • 17
  • 308
  • 431