????????????
????C++?н???????????????????????????????????鷯????????????????????????????????????飬??????????顣???????鶨??????????????????????????????????????????????????????????鶨????????????????????????
????struct bookInfo //???????bookInfo????鱾???
????{
????intid; //??????????????????id????鱾???
????charbookname[100]; //???????????????100???????????????????
????charauthor[100]; //??????????????????authorInfo????author??????????
????charpublisher[100]; //???????????????100???????????????????????
????};
????bookInfo book[3]; //???????3?????????????
??????
????struct bookInfo //???????bookInfo????鱾???
????{
????intid; //??????????????????id????鱾???
????charbookname[100]; //???????????????100???????????????????
????charauthor[100]; //??????????????????authorInfo????author??????????
????charpublisher[100]; //???????????????100???????????????????????
????}book[3]; //????????????????????飬?????????3????????????
????????????ж???????????????????顣???????嶨???????????????????顣???????????????????????????????????顣?y??????????5?????????????????????bookInfo?????????????????????????????????????????????????????????????
????bookInfo book[3] = {{1??”Linux”??”jack”??” OxfordUniversity Press”}??{2??”C++”??”jonh”??” Oxford University Press”}??
????{3??”java”??”lining”??”Oxford University Press”}};
????book[0].id = 4;
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????γ??????????????????????????????????????????????????????????????????ζ???????????????????
????????????????????????±??????У????????????±???“.”??????????????????????????е???????????book[0].id = 4??伴????±?????????????????y?????????????????id?????????????????????????????????????????????????????????????
????C++?????н??????????????????????????????????????????????????????????????????????????ó????е??????
????1.??????
??????UE??????????μ?????????????chapter0801.cpp???????????????makefile?????????FTP?????????Linux?????????????????scrt?????????????????????????????????
????/**
????* ???chapter0801
????* ????chapter0801.cpp
????* ??????????
????*/
????#include <iostream>
????using namespace std;
????struct record //???????record??????????????
????{
????int id; //?????????????id
????char data[20]; //?????????????data
????};
????/*
????* ?????????????????????????????
????* ??????????????????????????????鳤??
????* ?????????
????*/
????void showReacord(record *array??int length);
????int main()
????{
????record record_array[2] ={{1??"lining"}??{2??"jack"}}; //???????2????????????飬???????
????showReacord(record_array??2); //????????????????????
????return 0;
????}
????void showReacord(record *array??int length) //????????????????????????????
????{
????for(int i=0;i<length;i++) //???????????鳤?????????????????????
????{
????cout<<"The structarray"<<"["<<i<<"]:"<<endl; //????????????????????
????cout<<array[i].id<<""<<array[i].data<<endl; //?????????????????
????}
????}
????????????????????????????????????????????????????????????????????????????????????????????????????÷??????????????????????????????????????????????????????????????????????????????????鴛??????????????÷??????ɡ?
????2????makefile
????Linux????????????????chapter0801.cpp?????makefile?????????????????????????
????OBJECTS=chapter0801.o
????CC=g++
????chapter0801: $(OBJECTS)
????$(CC)$(OBJECTS) -g -o chapter0801
????clean:
????rm -fchapter0801 core $(OBJECTS)
????submit:
????cp -f -rchapter0801 ../bin
????cp -f -r*.h ../include
????????makefile?????????????????塣????????в???????????滻?????????????????????????滻????makefile????????п???????????????????????????????????????????????????г???????????????????ζ?????±?д?????????????????
????3?????????г???
???????shell?????make???????????г??????????????make submit????????????????????bin???????cd????λ?????bin??????иó?????????н???????????
????[developer@localhost src]$ make
????g++ -c -o chapter0801.o chapter0801.cpp
????g++ chapter0801.o -g -o chapter0801
????[developer @localhost src]$ make submit
????cp -f -r chapter0801 ../bin
????cp -f -r *.h ../include
????[developer @localhost src]$ cd ../bin
????[developer @localhost bin]$ ./chapter0801
????The struct array[0]:
????1 lining
????The struct array[1]:
????2 jack
?????????????????????????????塢???????????????????????????????±???????????????????????÷?????????С??????????????????????????????????????????????????????????????????????????????????????????????Linux???μ??????????????????????и??????á?