| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 자바 1676
- javav 1676
- 안정해시
- 백준 특정한 최단 경로
- spring mongodb switch
- spring mongodb
- kotiln const
- spring mongoTemplate
- ipfs bean
- 백준 1504 java
- Java Call By Refernce
- spring mongoTemplate switch
- kotiln const val
- kotiln functional interface
- rabbitmq 싱글톤
- ipfs singletone
- 백준 2252 줄세우기
- java 파티
- 자바 백준 팩토리얼 개수
- java 1509
- java 백준 1509
- go
- 백준 연결요소 자바
- mongodb lookup
- Claude Intelij 연결
- java 1238
- Spring ipfs
- java 팩토리얼 개수
- nodejs rabbitmq
- 익명 객체 @transactional
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 |
|---|