if(!strcmp(*u).name, " "))

 

if(strcmp( (*u).name, "") = 0)

 

boolean true;

if(!true)

'Computer Language > c 언어' 카테고리의 다른 글

문자열  (0) 2014.04.10
구조체 선언시 typedef  (0) 2014.04.10
NULL == '0' == 0  (0) 2014.04.10
라이브러리  (0) 2014.04.09
구조체 배열  (0) 2014.04.09

NULL == '0' == 0

CHAR형 뒤에는 널 값이 들어간다.

'Computer Language > c 언어' 카테고리의 다른 글

구조체 선언시 typedef  (0) 2014.04.10
strcmp 활용  (0) 2014.04.10
라이브러리  (0) 2014.04.09
구조체 배열  (0) 2014.04.09
열거자 에러를 선언시  (0) 2014.04.09

#include<stdio.h>

//1. 문자 길이
int strlen(char* s)
{
 char* temp = s;
 while (*++temp)
  ; /* not thing */

 return temp - s;

}
//2. 문자열 복사. source -> dest
void strcpy(char* dest, char* source)
{
 while (*dest++ = *source++)
  ; /*not thing*/
}

//3. strcmp(char * dest, char* source)
int strcmp(char* dest, char* source)
{
 for (; *dest && *source; dest++, source++){
  ; /* not thing*/
 }
 if (*source - *dest > 0){
  return 1;
 }
 else if (*source - *dest < 0){
  return -1;
 }
 else
  return *source - *dest;
}

// ASCII TO INTEGER 4. atoi(char *) : 문자 -> 숫자.
int atoi(char* source){
 int num = 0;
 for (; *source; source++)
 {
  num = 10 * num + *source - '0';
 }
 return num;
}
//5. integer to ascii : 숫자 -> 문자
void itoa(int num, char* src)

 //거꾸로 복사하고
 //num = 12345;
 char* temp = src;
 while (num > 0)
 {
  char c = num % 10 + '0';
  *temp++ = c;

  num = num / 10;
 }

 printf("text: %s \n", src);

 //리버스.
 //src = 54321
 //14325 -> 12345
 for (; --temp - src > 0; temp, src++)
 {
  char c = *src;
  *src = *temp;
  *temp = c;
 }
 
}

void main()
{
 char ch[10] = "1234";
 char temp[10] = "ab";

 printf("strlen(%s): %d \n", ch, strlen(ch));
 
 //strcpy(temp, ch);
 printf("strcpy(%s, temp) = > temp : %s \n", ch, temp);

 printf("strcmp(%s, %s) : %d \n", ch, temp, strcmp(ch, temp));

 printf("atoi(%s): %d \n", ch, atoi(ch));

 itoa(12340, ch);
 printf("itoa(12340, ch): %s \n", ch);
}

'Computer Language > c 언어' 카테고리의 다른 글

strcmp 활용  (0) 2014.04.10
NULL == '0' == 0  (0) 2014.04.10
구조체 배열  (0) 2014.04.09
열거자 에러를 선언시  (0) 2014.04.09
열거자  (0) 2014.04.09

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct phone
{
 char name[20];
 char number[20];
}Phone;

void add_phone(Phone* p, char* name, char* number)
{
 for (int i = 0; i < 10; i++)
 {
  if (strcmp(p[i].name, "") == 0 && strcmp(p[i].number, "") == 0){ //p[i].number이랑 "" 일시 0임.
   strcpy_s(p[i].name, name); //p[i].name에 name을 복사.
   strcpy_s(p[i].number, number);
   printf("%s %s \n", p[i].name, p[i].number);
   return;
  }
  
 }
 printf("넘쳐요\n");
}

void fine_phone(Phone* p, char* name)
{
 for (int i = 0; i < 10; i++)
 {
  if (strcmp(p[i].name, name) == 0){ //p[i].name이랑 name 일시 0임.
   printf("%s %s \n", p[i].name, p[i].number);
   return;
  }

 }
}
void del_phone(Phone* p, char* name, char* number)
{
 for (int i = 0; i < 10; i++)
 {
  if (strcmp(p[i].name, name) == 0 && strcmp(p[i].number, number) == 0){
   strcpy_s(p[i].name, "a");
   strcpy_s(p[i].number, "b");
   printf("name= %s number= %s \n", p[i].name, p[i].number);
   return;
  }
 }
}
void show_phone(Phone* p)
{
 for (int i = 0; i < 10; i++)
 {
  printf("name %s \t number %s\n", p[i].name, p[i].number);
 }
}

void main(){
 Phone phone[10] = {}; //10 full -> 더이상 저장할 수 없습니다

 for (int i = 0; i < 10; i++)
 {
  phone[i] = { "", "" };
 }

 add_phone(phone, "gameja1", "010-3344-5959");
 add_phone(phone, "gameja2", "010-3224-5959");
 add_phone(phone, "gameja3", "010-3344-5959");
 add_phone(phone, "gameja4", "010-3224-59533349");
 add_phone(phone, "gameja5", "010-3344-5923259");
 add_phone(phone, "gameja6", "010-3344-5959");
 add_phone(phone, "gameja7", "010-3224-5959");
 add_phone(phone, "gameja8", "010-3344-593239");
 add_phone(phone, "gameja9", "010-3344-5923259");
 add_phone(phone, "gameja10", "010-3344-5959");
 add_phone(phone, "gameja11", "010-3224-5959");
 add_phone(phone, "gameja12", "010-3344-593239");
 add_phone(phone, "gameja13", "010-3224-5959");
 add_phone(phone, "gameja14", "010-3344-593239");

 show_phone(phone);

 fine_phone(phone, "gameja4");

 del_phone(phone, "gameja1", "010-3344-5959");
}

 

 /*
 while (1){
  printf("1:입력\n");
  printf("2:출력\n");
  printf("3:종료\n");
  scanf_s("%d", &input, 1);

  switch (input)
  {
  case 1:
  {
      printf("이름/전화번호입력 : ");

  }
   break;

  case 2:
  {
      printf("이름\t\t전화번호\n");
      for (int i = 0; i < 10; i++)
      {
      // printf("%s\t\t%d\n",phone[count].name, phone[count].number, 1);
      }
  }
   break;

  case 3:
  {
      exit(0);
      break;
  }
  default:
   break;
  }
 }
}
*/

 

 

'Computer Language > c 언어' 카테고리의 다른 글

NULL == '0' == 0  (0) 2014.04.10
라이브러리  (0) 2014.04.09
열거자 에러를 선언시  (0) 2014.04.09
열거자  (0) 2014.04.09
구조체 p->age; (*p).age; 똑같다.  (0) 2014.04.09

// 열거타입 enum

#include<stdio.h>

typedef enum week
{
 ERROR_DONT_MOVE = 1,
 ERROR_DONT_HAVE_MONEY = 2,
 ERROR_SOCKET = 10
}ERROR;

void main()
{
 if (1)
 {
  printf("ERROR: %d, \n", ERROR_DONT_MOVE);
  printf("ERROR: %d, \n", ERROR_SOCKET);
 }
}

 

 

'Computer Language > c 언어' 카테고리의 다른 글

라이브러리  (0) 2014.04.09
구조체 배열  (0) 2014.04.09
열거자  (0) 2014.04.09
구조체 p->age; (*p).age; 똑같다.  (0) 2014.04.09
구조체  (0) 2014.04.09

// 열거타입 enum

#include<stdio.h>

enum week
{
 ONE = 2,  // 열거자 2로 초기화시 2, 3, 4 값이 들어가게 됨.
 TWO, THREE // .....
};

void main()
{
 enum week w;
 w = TWO;

 printf("%d, THREE:%d \n", w, THREE);
}

 

'Computer Language > c 언어' 카테고리의 다른 글

라이브러리  (0) 2014.04.09
구조체 배열  (0) 2014.04.09
열거자 에러를 선언시  (0) 2014.04.09
구조체 p->age; (*p).age; 똑같다.  (0) 2014.04.09
구조체  (0) 2014.04.09

#include<stdio.h>

typedef struct people{
 char* name1;
 int age;
 char* phone;
}People;

void main(){
 People peo = { "이민구", 24, "031-233-8444" };

 People* p = &peo;

 p->age;
 (*p).age;  똑같다.

 p->name1 = "exp";
 (*p).name1 = "exp2";

 printf("name1 : %s \n", p->name1);
 printf("age : %d \n", p->age);
 printf("phone : %s \n", p->phone);
}

'Computer Language > c 언어' 카테고리의 다른 글

라이브러리  (0) 2014.04.09
구조체 배열  (0) 2014.04.09
열거자 에러를 선언시  (0) 2014.04.09
열거자  (0) 2014.04.09
구조체  (0) 2014.04.09

//구조체 struct 이름 {}
//struct people{ };
#include<stdio.h>
#include<string.h>

typedef struct people
{
 char name[20];
 int age;
 char* phone;
}People;

void main()
{
 int n;
 typedef int myInt;
 myInt num = 10;

 People peo = {"abc", 10, "11-22"};
 
 People* p = &peo;

 printf("name: %s \n", p->name);
 printf("age : %d \n", p->age);
 printf("phone : %s \n", p->phone);
 /*
 char name[5] = "abcd";
 //char name[10] = { "abc", 10, "11-22" }; //구조체 초기화

 peo.age = 10;
 peo.phone = "123-456";
 strcpy_s(peo.name, 5, name);

 
 printf("people.name: %s \n", peo.name);
 printf("people.age: %d \n", peo.age);
 printf("people.age: %s \n", peo.phone);
 */
}

 

 

'Computer Language > c 언어' 카테고리의 다른 글

라이브러리  (0) 2014.04.09
구조체 배열  (0) 2014.04.09
열거자 에러를 선언시  (0) 2014.04.09
열거자  (0) 2014.04.09
구조체 p->age; (*p).age; 똑같다.  (0) 2014.04.09

using UnityEngine;

using System.Collections;


public class ExBank3 : MonoBehaviour {


// Use this for initialization

void Start () {

int deposit = 100;

int year = 10;

int total = GetTotal(deposit, 10, 5);

print ("Deposit =" + deposit + ", Total=" + total + ", Year = " + year);

}

int GetTotal(int deposit, int year, int percent) {

int total = deposit;

for(int i = 0; i < year; i++){

print (total);

total = total + total * percent / 100; //요기 부분

}

return total;

}

// Update is called once per frame

void Update () {

}

}


'Computer Language > 유니티' 카테고리의 다른 글

함수의 활용법.. 로그 이쁘게 찍기  (0) 2014.04.11
zzz  (0) 2014.04.11
단리  (0) 2014.04.08
입출금  (0) 2014.04.08
성적  (0) 2014.04.08

using UnityEngine;

using System.Collections;


public class ExBank3 : MonoBehaviour {


// Use this for initialization

void Start () {

int deposit = 1000000000;

int year = 10;

int total = GetDeposit1(deposit, 10, 5);

print ("Deposit =" + deposit + ", Total=" + total + ", Year = " + year);

}

int GetDeposit1(int deposit, int year, int percent) {

int total = deposit;

for(int i = 0; i < year; i++){

total = total + deposit * percent / 100;

print (total);

}

return total;

}

// Update is called once per frame

void Update () {

}

}




'Computer Language > 유니티' 카테고리의 다른 글

zzz  (0) 2014.04.11
복리  (0) 2014.04.08
입출금  (0) 2014.04.08
성적  (0) 2014.04.08
배열의 값을 비교(함수) 2가지 방법  (0) 2014.04.08

+ Recent posts