0
点赞
收藏
分享

微信扫一扫

使用scanf读入二维字符串数组注意事项


使用scanf("%c",&a[i][j])读入二维字符串数组时,

如果使用两个for循环,

要记得在内层循环结束后,使用getchar()读取换行符,

即:

for i ~ n

    for j ~ n

      scanf("%c",  &a[i][j])

     end

        getchar()

end

因为scanf("%c")会读入换行符;

或者就直接使用scanf("%s", a[i] )

for i~n

     scanf("%s", a[i] )

end


举报

相关推荐

0 条评论