- Get 방식  - 요청/응답 ( "http://127.0.0.1:8080/helloworld")

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
31
32
33
#include <curl/curl.h>
 
void request_get_helloworld(void) {
    CURL *curl;
    CURLcode res;
 
    struct memory data;
    char url[100={0};
 
    memset(&data, 0sizeof(data));
 
    curl = curl_easy_init();
    if(curl) {
        sprintf(url, "http://127.0.0.1:8080/helloworld");
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&data);
 
        res = curl_easy_perform(curl);
        if(CURLE_OK == res) {
            long status_code = 0;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status_code);
 
            printf("[status line] Status Code %ld \n", status_code);
            printf("[body] %s \n", data.response);            
        }else {
            printf("response is not OK : %d \n", res);
        }
    }
 
    /* always cleanup */
    curl_easy_cleanup(curl);
}
cs

- POST 방식 - 요청/응답 ( "http://127.0.0.1:8080/helloworld")

 

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
31
32
33
34
35
36
37
38
39
40
41
42
#include <curl/curl.h>
 
void request_post_helloworld(void) {
 
   CURL *curl;
   CURLcode res;
 
    struct memory data;
    char url[100={0};
    char post[100={0};
 
    memset(&data, 0sizeof(data));
 
    curl = curl_easy_init();
    if(curl) {
        sprintf(url, "http://127.0.0.1:8080/helloworld");
        sprintf(post, "Hello World");
 
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_POST, 1L); //POST request
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post); //POST request payload
        curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(post)); //POST request payload size
 
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&data);
 
        res = curl_easy_perform(curl);
        if(CURLE_OK == res) {
            long status_code = 0;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status_code);
 
            printf("[status line] Status Code %ld \n", status_code);
            printf("[body] %s \n", data.response);            
        }else {
            printf("response is not OK : %d \n", res);
        }
    }
 
    /* always cleanup */
    curl_easy_cleanup(curl);
 
}
cs

'프로그래밍 > C언어' 카테고리의 다른 글

Json C로 Json <-> string 변환  (0) 2022.07.11
연결리스트로 스택 만들기  (0) 2022.07.10
연결 리스트로 큐 생성  (0) 2022.07.10
Msg Queue  (0) 2022.06.14
파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23

아래 예제를 참고한다. 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <json-c/json.h>
 
json_object *myobj = json_object_new_object();
 
json_object_object_add(myobj,"name", json_object_new_string("KIM"));
json_object_object_add(myobj,"phone", json_object_new_string("01000000000"));
const char *result_json = json_object_to_json_string_next(myobj, JSON_C_TO_STRING_PLAIN);
 
printf("json:L %s \n", result_json);
 
json_object *root, *name, *phone;
root = json_tokener_parse(result_json);
json_object_object_get_ex(root, "name"&name);
json_object_object_get_ex(root, "phone"&phone);
 
printf("name : %s, phone : %s \n", json_object_get_string(name), json_object_get_string(phone));
 
 
cs

'프로그래밍 > C언어' 카테고리의 다른 글

curl 을 이용한 클라이언트 get , post 요청  (0) 2022.07.11
연결리스트로 스택 만들기  (0) 2022.07.10
연결 리스트로 큐 생성  (0) 2022.07.10
Msg Queue  (0) 2022.06.14
파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23

아래 링크를 참고했으며, 연결 리스트로 스택을 만듬 

 

https://ehpub.co.kr/c%EC%96%B8%EC%96%B4-%EC%86%8C%EC%8A%A4-%EC%8A%A4%ED%83%9D%EC%9D%84-%EC%97%B0%EA%B2%B0%EB%A6%AC%EC%8A%A4%ED%8A%B8%EB%A1%9C-%EA%B5%AC%ED%98%84/

 

[C언어 소스] 스택을 연결리스트로 구현 – 언제나 휴일

안녕하세요. 언제나 휴일입니다. 이번에는 스택(STACK)을 연결리스트로 구현하는 소스 코드입니다. 스택은 자료를 한쪽으로 보관하고 꺼내는 LIFO(Last In First Out) 방식의 자료구조입니다. 스택에 자

ehpub.co.kr

 

 

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
#include <stdio.h>
#include <stdlib.h>
 
 
typedef struct node {
    int data;
    struct node *next;
}Node;
 
typedef struct stack {
    Node *top;    
}Stack;
 
void InitStack(Stack *stack) {
    stack->top = NULL
}
 
int IsEmpty(Stack *stack) {
    return stack->top == NULL;    
}
 
void Push(Stack *stackint data) {
    Node *now = (Node *)malloc(sizeof(Node)); 
    now->data = data;
    now->next = stack->top;
    stack->top = now;   
}
 
int Pop(Stack *stack) {
    Node *now;
    int re;
    if (IsEmpty(stack))
    {
        return 0;
    }
    now = stack->top;
    re = now->data;
 
    stack->top = now->next;
    free(now);
    return re;
}
 
int main(void) {
    int i;
    Stack stack;
 
    InitStack(&stack);
    for (i = 1; i <= 5; i++)     {
        Push(&stack, i);
    }
 
    while (!IsEmpty(&stack))     {
        printf("%d ", Pop(&stack));
    }
    
    printf("\n");
    return 0;
}
 
 
cs

'프로그래밍 > C언어' 카테고리의 다른 글

curl 을 이용한 클라이언트 get , post 요청  (0) 2022.07.11
Json C로 Json <-> string 변환  (0) 2022.07.11
연결 리스트로 큐 생성  (0) 2022.07.10
Msg Queue  (0) 2022.06.14
파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23

코드의 소스는 아래 링크이며, 처음에 등록된 노드가 앞에 있고, 뒤로 등록된 노드들을 연결함 

 

https://ehpub.co.kr/c%EC%96%B8%EC%96%B4-%EC%86%8C%EC%8A%A4-%EC%8A%A4%ED%83%9D%EC%9D%84-%EC%97%B0%EA%B2%B0%EB%A6%AC%EC%8A%A4%ED%8A%B8%EB%A1%9C-%EA%B5%AC%ED%98%84/

 

[C언어 소스] 스택을 연결리스트로 구현 – 언제나 휴일

안녕하세요. 언제나 휴일입니다. 이번에는 스택(STACK)을 연결리스트로 구현하는 소스 코드입니다. 스택은 자료를 한쪽으로 보관하고 꺼내는 LIFO(Last In First Out) 방식의 자료구조입니다. 스택에 자

ehpub.co.kr

 

 

 

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct node {
    int data;
    struct node *next;
}Node;
 
typedef struct queue {
    Node *front
    Node *rear; 
    int count;
}Queue;
 
void InitQueue(Queue *queue){
    queue->front = queue->rear = NULL
    queue->count = 0;
}
 
int IsEmpty(Queue *queue){
    return queue->count == 0;    
}
 
void Enqueue(Queue *queueint data){
 
    Node *now = (Node *)malloc(sizeof(Node)); 
    now->data = data;
    now->next = NULL;
 
    if (IsEmpty(queue)) {
        queue->front = now;
    }else {
        queue->rear->next = now;
    }
 
    queue->rear = now;
    queue->count++;
}
 
int Dequeue(Queue *queue) {
    int re = 0;
    Node *now;
 
    if (IsEmpty(queue)) {
        return re;
    }
 
    now = queue->front;
    re = now->data;
    queue->front = now->next;
    free(now);
    queue->count--;
    return re;
}
 
int main(void)
{
    int i;
    Queue queue;
    InitQueue(&queue);
    for (i = 1; i <= 5; i++) {
        Enqueue(&queue, i);
    }
 
    while (!IsEmpty(&queue)) {
        printf("%d ", Dequeue(&queue));
    }
 
    printf("\n");
    return 0;
}
 
 
cs

'프로그래밍 > C언어' 카테고리의 다른 글

Json C로 Json <-> string 변환  (0) 2022.07.11
연결리스트로 스택 만들기  (0) 2022.07.10
Msg Queue  (0) 2022.06.14
파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23
directory 내 파일검색  (0) 2019.07.23

#include <stdio.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#define MAX 1024

struct message_buffer {
    int msg_type;
    char msg_text[MAX];
};

int read_line(char text[], int n);
void writer(int msg_id);
void reader(int msg_id);

int main() {

    int msg_id;

    pid_t pid; 

    msg_id = msgget(IPC_PRIVATE, 0600);
    if(msg_id == -1) {
        perror("msgget");
    }
    pid = fork();
    switch(pid) {
        case -1:
            perror("fork");
            break;
        case 0:
            reader(msg_id);
            break;
        default:
            writer(msg_id);
            break;
    }

    msgctrl(msg_id, IPC_RMID, NULL);
    return 0;
}

int read_line(char text[], int n) {
    char *ptext; 
    int return_value;
    int length;

    ptext = fgets(text, n, stdin);
    if(ptext == NULL) {
        return_value = EOF;
    }else {
        length = strlen(text);

        if(length > 0 && text[length-1] == '\n') {
            text[length-1] = '\0'; 
        }
        return_value != EOF;
        //return_value != EOF; ??
    }
    return return_value;
}

void writer(int msg_id) {
    struct message_buffer m;
    m.msg_type = 1;

    while(read_line(m.msg_text, MAX) != EOF) {
        int length;
        length = strlen(m.msg_text);

        if(msgsnd(msg_id, &m, length, 0) == -1) {
            perror("msgsnd");
            exit(1);
        }
        if(msgsnd(msg_id, &m, 0, 0) == -1) {
            perror("msgsnd");
            exit(1);
        }
    }
}

void reader(int msg_id) {
    int length, n=0;
    struct message_buffer m;

    while(length = msgrcv(msg_id, &m, MAX,0,0)) {
        n+= length;
    }
    if(length == -1) {
        perror("msgrcv");
        exit(1);
    }
    printf("Received number of bytes ")
}​

'프로그래밍 > C언어' 카테고리의 다른 글

연결리스트로 스택 만들기  (0) 2022.07.10
연결 리스트로 큐 생성  (0) 2022.07.10
파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23
directory 내 파일검색  (0) 2019.07.23
숫자 삽입  (0) 2019.06.27

파일 입출력 기본 함수 및 라인단위 읽고 쓰기 함수 예제

(관련 헤더는 stdio.h) 

#include <stdio.h>
  FILE *rfp = fopen(full_name,"r");
	FILE *wfp = fopen("file.txt","w");

	if(rfp == NULL) {
		printf("rfp -- not open \n");
		return 0;
	}
	if(wfp == NULL) {
		printf("wfp -- not open \n");
		return 0;
	}

	char rbuf[1024] = {0,};
	char wbuf[1024] = {0,};

	while(!feof(rfp)) {
		fgets(rbuf,sizeof(rbuf), rfp);
		strncpy(wbuf,rbuf,strlen(rbuf));
		fputs(wbuf,wfp);

		memset(rbuf,0x00,sizeof(rbuf));
		memset(wbuf,0x00,sizeof(wbuf));
	}
	fclose(rfp);
	fclose(wfp);

 

 

'프로그래밍 > C언어' 카테고리의 다른 글

연결 리스트로 큐 생성  (0) 2022.07.10
Msg Queue  (0) 2022.06.14
directory 내 파일검색  (0) 2019.07.23
숫자 삽입  (0) 2019.06.27
이차원배열  (0) 2019.06.27

특정 디렉토리 내에 포함된 파일 위치를 확인할 때 아래 코드를 참고한다. 

(path: 현재 폴더 위치("./BIGFILE") , file_name : 찾는 파일 명, full_path: 파일위치 최종 경로)

#include <dirent.h>
#include <sys/types.h>

void show_dir_content(char *path, char *file_name, char *full_path) {
	DIR *d = opendir(path);
	if(d==NULL) return;
	struct dirent *dir;

	while((dir = readdir(d)) != NULL)
	{
		if(dir->d_type != DT_DIR) {
			printf("%s\n",dir->d_name);
			if(!strcmp(file_name, dir->d_name)) {
				sprintf(full_path,"%s/%s",path, dir->d_name);
				closedir(d);
				printf("%s\n",full_path);
				return;
			}
		}else if(dir->d_type == DT_DIR && strcmp(dir->d_name,".")!=0 && strcmp(dir->d_name,"..")!=0) //if it is a directory
		{
			char d_path[256];
			sprintf(d_path,"%s/%s",path,dir->d_name);
			show_dir_content(d_path,file_name,full_path);
		}
	}
	closedir(d);
}

'프로그래밍 > C언어' 카테고리의 다른 글

Msg Queue  (0) 2022.06.14
파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23
숫자 삽입  (0) 2019.06.27
이차원배열  (0) 2019.06.27
기타 tip  (0) 2019.05.23

1) 특정 수를 기존 수 앞 뒤에 붙여 넣기 

int digit =0;
int tmpInputData = inputData;
//입력수 자릿수 확인 
while(tmpInputData != 0) {
	digit++;
	tmpInputData /= 10;
}
if(checkNum < 10) newNum = inputData*10 + checkNum;
else {
	int frontNum = checkNum/10;
	int endNum = checkNum%10;
	if(frontNum < endNum) {
		int tmp = frontNum;
		frontNum = endNum;
		endNum = tmp;
	}
	newNum = frontNum*(pow(10,digit+1)) + inputData*10 + endNum; 
}

 

'프로그래밍 > C언어' 카테고리의 다른 글

파일입출력, 라인단위 읽고쓰기  (0) 2019.07.23
directory 내 파일검색  (0) 2019.07.23
이차원배열  (0) 2019.06.27
기타 tip  (0) 2019.05.23
문자/숫자 식별/변환하는 라이브러리 함수 (isdigit, isalpha)  (0) 2019.05.23

1) 입력된 수만큼 키판 움직임 

   -  입력문자열  :  1U4D2R1L2D

   -  4*4 키판을 위에 입력 문자열 만큼 이동

void rotateNumberPad(int numberPad[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE], int arraySize, char rotationStr[MAX_DATA_LENGTH] {
	
	for(int i=0; i<strlen(rotationStr); i+=2 ) {
		char tmpStr[3] = {0,};
		strncpy(tmpStr, rotationStr+i, sizeof(char)*2);
		int direction = tmpStr[0] - '0';
		int isUpAndDown = 0;
		if(tmpStr[1] == 'U' || tmpStr[i] == 'D') {
			isUpAndDown =1;
			if(tmpStr[1] == 'U') direction *= -1;
		}else {
			isUpAndDown = 0;
			if(tmpStr[1] == 'L') direction *= -1;
		}
		rotateArr(numberPad, arraySize, direction,isUpAndDown);
	}
}

void rotateArr(int numberPad[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE], int arraySize, int direction, int isUpAndDown) {

	int tmpNumberPad[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE];
	memcpy(tmpNumberPad, numberPad, sizeof(int)*MAX_ARRAY_SIZE*MAX_ARRAY_SIZE);
	for(int i=0; i<arraySize; i++) {
		for(int j=0; j<arraySize; j++) {
			if(isUpAndDown == 1)  numberPad[(arraySize*arraySize+direction+i)%arraySize][j] = tmpNumberPad[i][j];
			else numberPad[i][(arraySize*arraySize+direction+j)%arraySize] = tmpNumberPad[i][j];
		}
	}
}

2) 배열 접기 

   -. 가로접기는 더하기, 세로접기는 곱하기로 마지막까지 접는 것 

   -. 짝수면 접고, 홀수면 가운데 제거 

   -. 가로 세로 접기 

 

void getFoldingArr(int foldingArr[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE], int *foldingArrCnt, int iniArr[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE], int arraySize) {

	memset(foldingArr,0, sizeof(int)*MAX_ARRAY_SIZE*MAX_ARRAY_SIZE); 
	*foldingArrCnt = 0;
	
	int center = arraySize/2; 
	
	//가로 접기
	for(int i=0; i<center; i++) {
		for(int j=0; j<arraySize; j++) {
			foldingArr[i][j] = iniArr[i][j] + iniArr[ArraySize-1-i][j];			
		}
	}
	
	//세로접기
	for(int i=0; i<center; i++) {
		for(int j=0; j<center; j++) {
			foldingArr[i][j] = foldingArr[i][j] * foldingArr[i][ArraySize-1-j];			
		}
	}
	*foldingArrCnt = center;
}

   - 배열크기가 홀수면 가운데 제거하고 다시 가로 세로 접기.. 최후 한개만 남을때까지 

void getFinalValue(int foldingArr[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE], int foldingArrCnt) {
	int arrSize =foldingArrCnt;
	while(1) {
		int tmpFoldingArr[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE];
		memset(tmpFoldingArr, 0, sizeof(int)*MAX_ARRAY_SIZE*MAX_ARRAY_SIZE);
		int newArr[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE];
		int newArrCnt=0;
		
		//홀수면 가운데 삭제 
		if(arrSize%2 == 1) {
			int center = round(arrSize/2);
			int indexI=0;
			int indexJ=0;
			for(int i=0; i<arrSize; i++) {
				if(i != center) {
					for(int j=0; j<arrSize; j++) {
						if(j != center) {
							tmpFoldingArr[indexI][indexJ] = foldingArr[i][j];
							indexJ++;
						}
					}
					indexI++;
					indexJ=0;
				}
			}
			memcpy(foldingArr,tmpFoldingArr, sizeof(int)*MAX_ARRAY_SIZE*MAX_ARRAY_SIZE);
			arrSize -= 1;
		}
		getFoldingArr(newArr, &newArrCnt, foldingArr, arrSize);
		arrSize = newArrCnt; 
		for(int i=0; i<newArrCnt; i++) {
			for(int i=0; i<newArrCnt; i++) {
				folding[i][j] = newArr[i][j];
			}
		}
		if(arrSize == 1) {
			finalValue = foldingArr[0][0];
			break;
		}
	}
}

3) 이차원배열 행렬 기준 오름차순 정렬 

//가로 오름차순 정렬
for(int i=0; i<arrSize; i++) {
	for(int j=0; j<arrSize; j++) {
		for(int k=j+1; k<arrSize; k++) {
			if(arr[i][j] > arr[i][k]) {
				int tmp = arr[i][j];
				arr[i][j] = arr[i][k];
				arr[i][k] = tmp;
			}
		}
	}
}

//세로 오름차순 정렬 
for(int i=0; i<arrSize; i++) {
	for(int j=0; j<arrSize; j++) {
		for(int k=j+1; k<arrSize; k++) {
			if(arr[j][i] > arr[k][i]) {
				int tmp = arr[j][i];
				arr[j][i] = arr[k][i];
				arr[k][i] = tmp;
			}
		}
	}
}

4) 이차원 배열 - 특정 지점에서 인접한 수가 동일하지 않는 경우만 합산 

int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};

//인접한 곳에 같은 수가 없는 경우만 합산
for(int i=0; i<arrSize; i++) {
	for(int j=0; j<arrSize; j++) {
		if(arr[i][j] != 0) {
			int flag=0;
			for(int k=0; k<4; k++) {
				int nx = i+dx[k];
				int ny = j+dy[k]; 
				if(nx<arrSize && nx>=0 && ny<arrSize ny>=0 )  {
					if(arr[i][j] == arr[nx][ny]) {
						flag=1;
						break;
					}
				}
			}
			if(flag == 0) arrSum += arr[i][j];
		}
	}
}

5. 이차원배열 달팽이 채우기 

void snale_matrix(){
    int matrix[5][5];
    int num=1;
    int delta=1;
    int limit=5;
    int i=0,j=-1;
 
    int p,q;
 
    while(1){
 
        //가로로 이동하면서 하나씩 할당
        for(p=0; p<limit; p++){
            j=j+delta;
            matrix[i][j]=num;
            num++;
        }
 
        //횟수 줄이고
        limit--;
 
        if(limit<0) break;
 
        //세로로 이동하면서 하나씩 할당
        for(p=0; p<limit; p++){
            i=i+delta;
            matrix[i][j]=num;
            num++;
        }
 
        //이동방향의 양음이 바뀜
        delta=-delta;
    }
 
    //2차원 배열 출력
    for(p=0; p<5; p++){
        for(q=0; q<5; q++){
            printf("%d\t",matrix[p][q]);
        }
        printf("\n");
    }
 
}

6) 이차원배열내 특정 위치에서 '1'이 연속하여 이어진 갯수 

size =0, copiedData: 이차원배열, x/y : 특정 위치 
int checkTerritory(copiedData, x, y, size) {
	if(copiedData[x][y] == '1') {
		copiedData[x][y] == '2';
		size++;
		
		if(x>0) size = checkTerritory(copiedData, x-1, y, size);
		if(y>0) size = checkTerritory(copiedData, x, y-1, size);
		if(x<MAX-1) size = checkTerritory(copiedData, x+1, y, size);
		if(y< MAX-1) size = checkTerritory(copiedData, x, y+1, size);
		
		return size;		
	}else 
		return size;
}

7) 이차원 배열 전 구간에 영역별 크기 계산 (위의 6번 함수 이용)

만약 전체 경로에서 "1"이 연속된 곳의 위치를 계산하고, 크기순으로 오름차순으로 하면 
for(int i=0; i<MAX; i++) {
	for(int j=0; j<MAX; j++) {
		int tmpSize =0;
		tmpSize = checkTerritory(copiedData, i, j, tmpSize);		
		if(tmpSize) {
			terrSize[(*terrCnt)++] = tmpSize;
		}
	}
} 

//크기순으로 오름차순 정렬
for(int i=0; i<*terrCnt; i++) {
	for(int j=0; j<*terrCnt; j++) {
		if(terrSize[i] > terrSize[j]) {
			int tmp = terrSize[i];
			terrSize[i] = terrSize[j];
			terrSize[j] = tmp;
		}
	}
}

 

 

 

'프로그래밍 > C언어' 카테고리의 다른 글

directory 내 파일검색  (0) 2019.07.23
숫자 삽입  (0) 2019.06.27
기타 tip  (0) 2019.05.23
문자/숫자 식별/변환하는 라이브러리 함수 (isdigit, isalpha)  (0) 2019.05.23
정렬  (0) 2019.05.23

1) 홀수 짝수 번갈아 입력 시 : if(i%2) ... else .. . 형식으로 사용 

2) 함수 매개변수로 포인터 받아 그 값을 증가 할 때 : terry[ (*terrCnt)++]

3) 반올림 : 

   예) 10자리 반올림 : (number + 50)/100*100

4) 부호 있는 정수 / 부호없는 정수 최대 / 최소 값 (limit.h)    

    int INT_MIN INT_MAX

    unsigned int 0 UINT_MAX

5) 배열 count 없이 strlen으로 값을 계속 입력 

char arrStr[MAX] = {0,};
arrStr[strlen(arrStr)] = input[i];

 

 

 

'프로그래밍 > C언어' 카테고리의 다른 글

숫자 삽입  (0) 2019.06.27
이차원배열  (0) 2019.06.27
문자/숫자 식별/변환하는 라이브러리 함수 (isdigit, isalpha)  (0) 2019.05.23
정렬  (0) 2019.05.23
진법변환  (0) 2019.05.23

+ Recent posts