简体   繁体   中英

issue with char TypeDef

When I try to copy the data from a string into this typdef char by char, the debugger shows everything going in properly, but when it ouputs, it outputs the data plus garbage data. When I tried to see the length of the items each instance of scores, the size is over 700, when it should be 30. Anyone know whats going on?

const int NUMBEROFQUESTIONS= 30;
typedef char answerSet[NUMBEROFQUESTIONS];

getline(testResults, x, '\n');
        testResults.getline(scores[count],'\n');

        for(int j=0; j< 25; j++){
            for(int i =0; i < 30;i++){
                scores[j][i] = x[i];
            }
        }

如果要以字符串形式查看输出,则应在数组的末尾加上“ \\ 0”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM