所以我有這個簡單的數據結構,我想打印它的所有字符,但我不能指定n到n.next。我用java編程了一下,這種工作起作用了。這段代碼有什麼問題?不能分配結構到結構的指針
#include <iostream>
using namespace std;
struct node{
char c;
struct node *next;
struct node *prev;
};
typedef struct node NODE;
void printnode(NODE n){
while(n.next){
cout << n.c;
n=n.next;
}
}
指針是保存地址的完全獨立的類型。它們與它們指向的類型完全不兼容。 – chris
你是什麼意思「我不能指派」?什麼是錯誤? – 4pie0