== 대근 == {{{~cpp ==================================================================== // 1번 프로그래밍 연습... #include using namespace std; void print(char *,int n=0); int main() { char exam[40]; int choice; do { cout << "문자열(20자내)을 입력하세요...\n"; cin.getline(exam,40); cout << "숫자를 입력하세요.. _\b"; cin >> choice; cin.get(); print(exam,choice); }while(choice==0); return 0; } void print(char *exam,int n) { static int count=0; if(n==0) cout << exam << endl; else { cout << "당신은 출력 함수를 " << count << " 번 사용하셨습니다.\n"; for(int i=0;i using namespace std; struct candybar { char name[30]; double weight; int cal; }candy; void print(candybar &, char * name="millenium Munch",double weight=2.85,int cal=350); int main() { print(candy); return 0; } void print(candybar &candy,char * name,double weight,int cal) { for(int i=0;i<30;i++) candy.name[i]=name[i]; candy.weight=weight; candy.cal=cal; cout << "캔디바의 이름\t:\t" << candy.name < using namespace std; #include struct stringy { char * str; int ct; }; void show(char *, int n=1); void show(stringy, int n=1); void set(stringy &,char *); int main() { stringy beany; char testing[] = "Reality isn't what it used to be."; set(beany,testing); show(beany); show(beany,2); testing[0]='D'; testing[1]='u'; show(testing); show(testing,3); show("Done!"); return 0; } void show(char *string,int n) { for(int i=0;i #include using namespace std; const int Len=40; struct golf { char fullname[Len]; int handicap; }g1,g2; //함수는 사용자에게 이름과 핸디켑을 요구한다 //이름이 입력되면 1을 리턴하고, 이름이 빈 문자열이면 0을 리턴한다 int setgolf(golf & g); //함수는 전달인자로 전달된 값들을 사용하여 //golf 구조체를 제곤된 이름과 핸디캡으로 설정한다 void setgolf(golf & g, const char * name, int hc); //함수는 handicap을 새값으로 초기화한다. void handicap(golf & g, int hc); //함수는 golf 구조체의 이름을 표시한다 void showgolf(const golf & g); int main() { int k; do { k=setgolf(g1); setgolf(g2, "DKNY", 100); handicap(g2,77); showgolf(g1); cout<> g.fullname; cout << "Handicap?\n"; cin >> g.handicap; if(g.fullname==NULL) return 0; else return 1; } void setgolf(golf & g, const char * name, int hc) { strcpy(g.fullname,name); g.handicap=hc; } void handicap(golf & g, int hc) { g.handicap=hc; } void showgolf(const golf & g) { cout << "Name \t:\t" << g.fullname << endl; cout << "HandyCap\t:\t" << g.handicap << endl; } ============================================================= }}}