일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 전략 패턴이란
- spring mongodb
- 자바 1676
- spring mongoTemplate switch
- 익명 객체 @transactional
- kotiln const
- ipfs bean
- rabbitmq 싱글톤
- kotiln const val
- 자바 백준 팩토리얼 개수
- spring mongoTemplate
- 백준 특정한 최단 경로
- 백준 1504 java
- Spring ipfs
- mongodb lookup
- java 팩토리얼 개수
- 백준 2252 줄세우기
- ipfs singletone
- javav 1676
- java 1509
- kotiln functional interface
- 안정해시
- java 백준 1509
- go
- 백준 연결요소 자바
- spring mongodb switch
- java 파티
- Java Call By Refernce
- java 1238
- nodejs rabbitmq
Archives
- Today
- Total
공부 흔적남기기
c언어 문자열을 입력받고 길이리턴하기 본문
728x90
반응형
#include <stdio.h>
#include <ctype.h>
int read_line_with_compression(char *compressed, const int limit);
int main()
{
char line[100];
while (1)
{
printf("$ ");
int length = read_line_with_compression(line, 100);
printf("%s : %d\n", line, length);
}
return 0;
}
int read_line_with_compression(char *compressed, const int limit)
{
int ch; int i = 0;
while ((ch = getchar()) != '\n')
{
if (i < limit - 1 && (!isspace(ch)) || i >0 && !isspace(compressed[i - 1]))
{
compressed[i++] = ch;
}
}
if (i > 0 && isspace(compressed[i - 1]))
i--;
compressed[i] = '\0';
return i;
}
//c로 배우는 자료구조 및 여러가지 예제 실습 by권오흠교수님 in 인프런
728x90
반응형
'프로그래밍 언어 > c study' 카테고리의 다른 글
c 언어 전화번호부 .version.1.0 (0) | 2021.02.19 |
---|