달력

62025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>      // 시간과 관련된 함수가 들어있는 헤더파일


struct user        // 회원에 대한 정보를 보관하기 위한 배열
{
 char name[11];
 int nai;
 char sung;
 char phone[12];
};

void input(struct user *data, int *cnt)
{
 printf("이름 : ");
 scanf("%s", data[*cnt].name);
 printf("나이 : ");
 scanf("%d", data[*cnt].nai);
 printf("성별 : ");
 fflush(stdin);
 scanf("%c", data[*cnt].sung);
 printf("전번 : ");
 scanf("%s", data[*cnt].phone);
 (*cnt)++;
}

void del (struct user *data, int *cnt)
{
}

void search(struct user *data, int cnt)
{
 int i;
 char sdata[11];
 printf("찾을 이름을 입력 : ");
 scanf("%s", sdata);
 for(i=0;i<cnt;i++)
 {
  if(strcmp(sdata, data[i].name)==0)
  {
   printf("%d번 회원입니다.\n", i+1);
   return;
  }
 }
 printf("그런 회원 없습니다.\n");
}

void main ( )
{
 struct user data[10];    // 10명의 회원정보를 보관하기 위한 배열
 int cnt=0;       // 회원의 숫자를 보관할 변수
 int in;
 
 while (1)
 {
  printf("메뉴를 선택하세요 : \n", cnt);
  printf("1. 회원 추가\n");
  printf("2. 회원 삭제\n");
  printf("3. 회원 검색\n");
  printf("4. 종료\n");
  printf("입력 : ");
  scanf("%d", &in);
  if (in==1)
   input(data, &cnt);
  else if (in==2)
   del(data, &cnt);
  else if (in==3)
   search(data, cnt);
  else if (in==4)
   break;
 }
}

 

/*
struct user
{
 int nai;
 double ki;
};

void main ( )
{
 struct user a = {10,150.5};
 struct user *sp;     // struct user형 변수의 주소값을 보관할 포인터 변수 sp

 printf(" &a = %p\n", &a);
 printf(" &a.nai = %p\n", &a.nai);
 printf(" &a.ki = %p\n", &a.ki);

 sp = &a;
 printf("(*sp).nai = %d\n",(*sp).nai);
 printf("(*sp).ki = %lf\n",(*sp).ki);

 // ->는 간접멤버참조연산자 이며 "가리키는놈 안에 있는" 이라 읽는다.
 printf("sp->nai = %d\n", sp->nai);
 printf("sp->ki = %lf\n", sp->ki);
}
*/

/*
struct lemon       // date type lemon의 선언
{
 int color;       //멤버변수 color
 int size;       // 멤버변수 size
};

void func (struct lemon x)
{
 printf("x.color = %d\n", x.color);   
 printf("x.size = %d\n", x.size);   
 x.color = 2;
 x.size = 20;
}

void main ( )
{
 struct lemon a, b;      // 구조체 lemon형으로 변수 a와 b를 선언
 printf("sizepf(a) = %d\n", sizeof(a));  // 구조체형 변수의 크기는
            // 멤버변수의 크기 합과 같다.

 // a = 10; // 에러 : 구조체형 변수는 직접 연산이 불가능하다.
 // a++;    // 에러 : 구조체형 변수는 직접 연산이 불가능하다.

 a.color = 1;   // 구조체형 변수 안에 있는 멤버변수를 호출해 사용
 a.size = 10;   // .연산자는 직접멤버연산자라 부리며 "안에있는" 이라고 읽는다.
 
 printf("a.color = %d\n", a.color);   // 1
 printf("a.size = %d\n", a.size);   // 10

 b = a;    // 같은 자료형을 가지는 구조형 변수끼리 대입은 가능하다.

 printf("b.color = %d\n", b.color);   // 1
 printf("b.size = %d\n", b.size);   // 10

 func(a);   // 구조체형 변수를 매개변수로 건네주는 방법

}
*/

/*
void main ( )
{
 int i;
 srand( time(NULL) );
 for (i=1;i<=10;i++)
 {
  printf("%d\n", rand( ) );
 }
}
*/

/*
void main ( )
{
 char dap[16] = "aaabbbcccdddeee";
 char chk[16] = {0};
 int i;

 while(1)
 cht
 for(i=0; i<=15; i++)
 {
  if (chk[i]==0)
   printf("□");
  else
   printf("%c", dap[i]);
 }
 printf("\n",da[);
 printf("입력 : ");
 fflust(stdin);
 scanf("%c" &in);
 for ( i = 0; u<=15; i++)
 {
  if (dap[i] == in)
   chk[i]=1;
 }
 for(i =0; i<=14; i++)
 {
  if(chk[i]==s1)
   cnt++;
 }
 if(cbt==15;)
  printf("승리");
 break;
 }
 printf("문제 = %s", dap);
}
*/

/*
void main ( )
{
 char a[11], b[11], c[11], d[11];

 strcpy(a, "korea");    // 문자열 복사 함수
 printf("a =  %s\n", a);

 strcat(a, "team");    // 문자열 결합 함수
 printf("a =  %s\n", a);

 strcpy(b, "japan");    
 printf("strcmp(a,b) = %d\n", strcmp(a,b));  // 문자열 비교 함수
 printf("strlen(a) = %d\n", strlen(a));
 printf("strchr(a,'t') = %p\n", strchr(a,'t'));
}
*/

/*
void f1 (int x[], int y[][3], int z[][2][3])
{
 printf("x[0] = %d\n", x[0]);
 printf("x[1] = %d\n", x[1]);

 printf("y[0][0] = %d\n", y[0][0]);
 printf("y[0][1] = %d\n", y[0][1]);
 printf("y[0][2] = %d\n", y[0][2]);
 printf("y[1][0] = %d\n", y[1][0]);
 printf("y[1][1] = %d\n", y[1][1]);
 printf("y[1][2] = %d\n", y[1][2]);
 printf("y[2][0] = %d\n", y[2][0]);
 printf("y[2][1] = %d\n", y[2][1]);
 printf("y[2][2] = %d\n", y[2][2]);

 printf("z[0][0][0] = %d\n", z[0][0][0]);
 printf("z[0][0][1] = %d\n", z[0][0][1]);
 printf("z[0][1][0] = %d\n", z[0][1][0]);
 printf("z[1][0][0] = %d\n", z[1][0][0]);
 printf("z[1][0][2] = %d\n", z[1][0][2]);

}

void f2(int *x, int (*y)[3], int (*z)[2][3] )
{
 printf("x[0] = %d\n", x[0]);    // 10
 printf("y[1][2] = %d\n", y[1][2]);   // 60
 printf("y[1][0][2] = %d\n", z[1][0][2]); // 90
}

int *f3( )
{
 int arr[4] = {10,20,30,40};
 return arr;
}


void main ( )
{
 int a[3] = {10,20,30};
 int b[2][3] = {10,20,30,40,50,60};
 int c[2][2][3] = {10,20,30,40,50,60,770,80,90,100,110,120};
 int *ip;
 f1(a,b,c);
 f2(a,b,c);
 ip = f3( );        // 배열 전체를 리턴 받아 사용하는 것은 불가능하다.
 printf("ip[0] = %d\n", ip[0]);
 printf("ip[1] = %d\n", ip[1]);
 printf("ip[2] = %d\n", ip[2]);
}
*/

/*
void main ( )
{
 const int a = 10;    // 상수형 int a가 만들어 진다.
 const int x = 30;
 int b = 20;
 
 const int *ip = &a;    // const int의 주소값을 보관할수 있는 포인터 변수 ip
 
 // *ip = 40; // 에러 : a가 상수임으로 역참조를 통해 값을 바꿀수 없다.
 
 int * const jp = &b;   // int의 주소값을 보관할수 있는 포인터 상수 jp
 const int * const kp = &a;  // const int의 주소값을 보관할 수 있는 포인터 상수 kp

 int * const jp = &b;   // int의 주소값을 보관할수 있는  포인터 상수 jp
 ip = &x;      // ip는 변수임으로 값을 변경할 수 있다.
}
*/

'매니저 > C' 카테고리의 다른 글

20120313 학원  (0) 2012.03.13
20120312 학원  (0) 2012.03.12
C언어 2011.08.27 (미검사)  (0) 2011.10.13
C언어 2011.08.22 (미검사)  (0) 2011.10.13
C언어 2011.08.21 (미검사)  (0) 2011.10.13
Posted by cdprkr2077
|