아래 코드에서 구조체 및 시프트 참조 배열의 멤버에 액세스하려고합니다. 그것은 배열 인덱스에 있습니다.
구조에 액세스 할 때 invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
오류가 발생합니다. 인덱스에 대한 참조가 cstring의 표시로 읽혀지는 것 같습니다. 이 컨텍스트에서 struct 멤버에 어떻게 액세스합니까? 뭐가 잘못 되었 니?int 형식 오류 인 struct 멤버 수정 : 'int'에서 'const char *'로의 잘못된 변환
void removeSong (Song songList[], int& size){
int indexRem;
int i;
cout << "Input index to remove" << endl;
cin >> indexRem;
//Error checking for correct index(0 and 1 less than count) needed
for(i = indexRem; i < size; i++){
songList[i] = songList[i+1];
}
strcpy(songList[i].title, songList[i+1].title);
strcpy(songList[i].artist, songList[i+1].artist);
strcpy(songList[i].album, songList[i+1].album);
strcpy(songList[i].min, songList[i+1].min);
strcpy(songList[i].sec, songList[i+1].sec);
size--;
}
편집 :이 질문은 c- 문자열과의 잘못된 관계를 나타냅니다. 문제는 strcpy 함수를 부적절하게 사용하는 것입니다.
오류에 관해서는, * 어디서 얻을 수 있습니까? 구조가 어떻게 생겼습니까? –
char 배열 대신'std :: vector'및'std :: string'을 사용할 수없는 이유는 무엇입니까? –
PaulMcKenzie
오류는'strcpy (songList [i] .min, songList [i + 1] .min);에서 발생합니다. strcpy (songList [i] .sec, songList [i + 1] .sec); ' – 0x1000001