从 ssh 中不兼容的指针类型赋值
assignment from incompatible pointer type in ssh
我需要你的帮助..
我构建了 3 个结构:
歌曲、歌曲列表和音乐专辑。
我在 ssh 中收到消息警告:"assignment from incompatible pointer type"
根据我在它们旁边写的两行:// problem
typedef struct
{
char* nameSong;
char* nameSinger;
int lenghtOfSong;
struct song *next;
struct song *prev;
} song;
typedef struct
{
song* head;
song* tail;
} listOfsong;
typedef struct
{
int yearOfpublication;
listOfsong* listOfSongs;
int numbersOfSongs;
} musicAlbum;
song* SongCreate()
{
song *songInput =(song*) malloc(sizeof(song));
//free
songInput->nameSong = StringName();
songInput->nameSinger = StringName();
scanf("%d", &songInput->lenghtOfSong);
songInput->next = NULL;
songInput->prev = NULL;
return songInput;
}
void AddSongToList(musicAlbum *pmusicAlbum)
{
if (pmusicAlbum->listOfSongs == NULL)
{
pmusicAlbum->listOfSongs = (listOfsong*)malloc(sizeof(listOfsong));
song *newSong=SongCreate();
pmusicAlbum->listOfSongs->head = newSong;
pmusicAlbum->listOfSongs->tail = newSong;
}
else
{
song *newSong = SongCreate();
newSong->prev = pmusicAlbum->listOfSongs->tail;// problem
pmusicAlbum->listOfSongs->tail->next = newSong; // problem
pmusicAlbum->listOfSongs->tail = newSong;
}
}
有人知道这是什么意思吗?
它出现在我项目的其他地方
谢谢。
改变这个
typedef struct
{
char* nameSong;
char* nameSinger;
int lenghtOfSong;
struct song *next;
struct song *prev;
} song;
至
typedef struct song song;
struct song
{
char* nameSong;
char* nameSinger;
int lenghtOfSong;
struct song *next;
struct song *prev;
};
我需要你的帮助.. 我构建了 3 个结构: 歌曲、歌曲列表和音乐专辑。
我在 ssh 中收到消息警告:"assignment from incompatible pointer type" 根据我在它们旁边写的两行:// problem
typedef struct
{
char* nameSong;
char* nameSinger;
int lenghtOfSong;
struct song *next;
struct song *prev;
} song;
typedef struct
{
song* head;
song* tail;
} listOfsong;
typedef struct
{
int yearOfpublication;
listOfsong* listOfSongs;
int numbersOfSongs;
} musicAlbum;
song* SongCreate()
{
song *songInput =(song*) malloc(sizeof(song));
//free
songInput->nameSong = StringName();
songInput->nameSinger = StringName();
scanf("%d", &songInput->lenghtOfSong);
songInput->next = NULL;
songInput->prev = NULL;
return songInput;
}
void AddSongToList(musicAlbum *pmusicAlbum)
{
if (pmusicAlbum->listOfSongs == NULL)
{
pmusicAlbum->listOfSongs = (listOfsong*)malloc(sizeof(listOfsong));
song *newSong=SongCreate();
pmusicAlbum->listOfSongs->head = newSong;
pmusicAlbum->listOfSongs->tail = newSong;
}
else
{
song *newSong = SongCreate();
newSong->prev = pmusicAlbum->listOfSongs->tail;// problem
pmusicAlbum->listOfSongs->tail->next = newSong; // problem
pmusicAlbum->listOfSongs->tail = newSong;
}
}
有人知道这是什么意思吗? 它出现在我项目的其他地方
谢谢。
改变这个
typedef struct
{
char* nameSong;
char* nameSinger;
int lenghtOfSong;
struct song *next;
struct song *prev;
} song;
至
typedef struct song song;
struct song
{
char* nameSong;
char* nameSinger;
int lenghtOfSong;
struct song *next;
struct song *prev;
};