0
Ich bin es wieder mit diesem Projekt. Ich habe ein Problem beim Lesen des Textes auf meiner Eingabe, weil das Programm nie endet. Das Problem ist hier full description of the problem , aber ich weiß nicht, wie man den Text char von Char lesen, und lesen Sie dann die nächste Zeile auf die gleiche Weise.Wie liest man einen Text char durch char und Zeile für Zeile auf C++?
freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);
int n=-1;
int m=-1;
int cont =0;
int VMatriz[100][100]={0};
int Mapa[100][100]={0};
while(n!=0 && m!=0)
{
scanf("%d %d",&n,&m);
if (n==0 && m==0)
break;
cont++;
printf("Field # %d",cont);
for (int i=0;i<n;i++)
{ printf("/n");
for (int j=0;j<m;j++)
{
//scanf("%d ",&Mapa[i][j]);
Mapa[i][j]=getchar();
if (Mapa[i][j]=='*')
{
if (j-1>=0)
VMatriz[i][j-1]++;
if (j+1<m)
VMatriz[i][j+1]++;
if (i-1>=0)
VMatriz[i-1][j]++;
if (i+1<m)
VMatriz[i+1][j]++;
if (j-1>=0 && i-1>0)
VMatriz[i-1][j-1]++;
if (j-1>=0 && i+1<m)
VMatriz[i+1][j-1]++;
if (j+1<m && i-1>0)
VMatriz[i-1][j+1]++;
if (j+1<m && i+1<m)
VMatriz[i+1][j+1]++;
VMatriz[i][j]='*';
printf("%d",VMatriz[i][j]);
}
}
}
printf("/n");
}
return 0;