0
我正在输入2D字符数组,并且必须在用户按下回车键时停止输入。但是我的代码没有显示任何输出。
输入:输入2d字符数组时出错
5 // where this is the number of columns,
// number of rows are unknown so have taken maximum rows as: 40
阵列:
toioynnkpheleaigshareconhtomesnlewx
预期输出:
i = 7, j = 5
这里是我的代码:
int main(){
char a[100][100];
int n, i, j, p, q;
cin >> n;
if(n==0)
exit(0);
for(i = 0; i < 40; i++){
for(j = 0; j < n; j++){
cin >> a[i][j];
if(a[i][j]==13) // 13 = ASCII code for enter key
goto jump;
}
}
jump:
cout<<i<<"\n"<<j<<"\n";
}
但它不打印任何东西。
它有什么问题?
它仍然无法正常工作 – Knight
尝试将if条件更改为:if(a [i] [j] =='\ n')'而不是将该值与13进行比较。 –
仍然不起作用 – Knight