मैं एक पुराने सी किताब [एएनएसआई सी का एक फर्स्ट बुक] में से कुछ उदाहरण कर रहा हूँ और एक त्रुटि हो रही है इस उदाहरण कोड को संकलित करने का प्रयास करते समय से उदाहरण संकलन:त्रुटियाँ एएनएसआई सी किताब, लिंक्ड सूचियाँ अध्याय
#include <stdio.h>
struct tele_typ {
char name[30];
char phone_no[15];
struct tele_typ *nextaddr;
};
main() {
struct tele_typ t1 = {"Acme, Sam", "(201) 555-6678"};
struct tele_typ t2 = {"Dolan, Edith", "(213) 682-3104"};
struct tele_typ t3 = {"Lanfrank, John", "(415) 718-4581"};
tele_typ *first; /* create a pointer to a structure */
first = &t1; /* store t1's address in first */
t1.nextaddr = &t2; /* store t2's address in t1.nextaddr */
t2.nextaddr = &t3; /* store t3's address in t2.nextaddr */
t3.nextaddr = NULL; /* store the NULL address in t3.nextaddr */
printf("\n%s %s %s",first->name,t1.nextaddr->name,t2.nextaddr->name);
}
gcc newstruct.c -o newstruct
से उत्पादन ..और:
newstruct.c: In function 'main':
newstruct.c:13:3: error: unknown type name 'tele_typ'
newstruct.c:15:9: warning: assignment from incompatible pointer type [enabled by default]
newstruct.c:20:28: error: request for member 'name' in something not a structure or union
यह लिंक्ड सूचियों पर अध्याय 10.4 है। क्या किताब में कोई त्रुटि है? या मानकों/gcc version 4.6.2 20120120 (prerelease)
में कुछ बदल गया है? धन्यवाद!
क्या आप पुस्तक में कोड देख सकते हैं? क्या यह वास्तव में 'tele_typ * पहले घोषित करता है; ', और पहले' tele_type * struct 'नहीं;'? या आपने इसे टाइप करते समय 'स्ट्रक्चर' कीवर्ड को याद किया था? –
[पुस्तक] का कौन सा संस्करण (http://www.amazon.com/First-Book-Fourth-Iprroduction-Programming/dp/1418835560) क्या आप इसका उपयोग कर रहे हैं? (पेपरबैक के लिए $ 166.95 सूची मूल्य? वास्तव में?) –
यहां कीथ की एक तस्वीर है: http://i.imgur.com/hXnwX.jpg द्वितीय संस्करण, आईएसबीएन: 0-314-01086-6 एक दोस्त मुझे कुछ साल पहले किताब दी। मैं सी सीखने की कोशिश करने से विचलित हो गया (पाइथन पर लगा हुआ ...) और फिर से दिलचस्पी लेना शुरू कर दिया है :) – nak