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