0
我是新來的c + +,我一直在嘗試處理輸入的串聯。我有一個用戶輸入的名字和姓氏,以及假社會保障的最後四位數字。然後,我想通過取第一個名字的第一個字母,姓氏的第一個字母和四個數字來將它們加在一起。每次我運行我的程序時,都會彈出一個錯誤消息,提示非類型。 錯誤:關於非類型錯誤的問題?
In function 'int main()': 89:26: error: request for member 'at' in 'firstname[i]', which is of non-class type 'string2 {aka char [3]}' 90:26: error: request for member 'at' in 'lastname[i]', which is of non-c`enter code here`lass type 'string2 {aka char [3]}'
typedef char string2[size];
string2 firstname[size];
string2 lastname[size];
string2 middleinitial[size];
string2 lastfour[size];
//CONCATINATION FOR ID
string id[size];
for (int i = 0; i < size; i ++)
{
id [i] = firstname[i].at (0);//set id = to first letter of the first name
id [i] += lastname[i].at (1);//concatinate the first letter of the last name to the id
id [i] += lastfour[i]; //concatinate the last four
}
請改用'firstname [i] [0]'。 – songyuanyao