C 8byte hello world
#include <unistd.h>
struct b5
{
unsigned int i0 : 5;
unsigned int i1 : 5;
unsigned int i2 : 5;
unsigned int i3 : 5;
unsigned int i4 : 5;
unsigned int i5 : 5;
} const stream[] = { {0x4, 0x1, 0x8, 0x8, 0xB, 0x14}, {0x13, 0xB, 0xE, 0x8, 0x0, 0x15} };
#define B5AT_1(o, index) (o.i##index)
#define B5AT_2(o, i, dex) dex == i ? B5AT_1(o, i) :
#define B5AT_3(o, i) B5AT_2(o, 0, i)B5AT_2(o, 1, i)B5AT_2(o, 2, i)B5AT_2(o, 3, i)B5AT_2(o, 4, i)B5AT_2(o, 5, i)0
#define B5AT(o, i) (B5AT_3(o, i))
unsigned char b5ToCh(const struct b5 arr, const unsigned char index)
{
unsigned char ch = B5AT(arr, index);
switch( ch )
{
case 0x14: return ' ';
case 0x15: return '\n';
default: return ch + 'd';
}
return '\0';
}
#undef B5AT
#undef B5AT_1
#undef B5AT_2
#undef B5AT_3
#define ARR_FOR(type, it, arr) for( type * it = arr ; it != arr + sizeof( arr ) / sizeof ( type ) ; it ++ )
int main() {
char ch;
ARR_FOR(struct b5, it, stream) for(int i = 0; i < 6; i++) ch = b5ToCh(*it, i), write(STDOUT_FILENO, &ch, 1);
return 0;
}
#undef ARR_FOR8바이트 정도인걸 출력하는 구문도 만들려다가 간결한 코드가 복잡해지는 것 같아서 제외했음
ch = sizeof( stream ) + '0'; write(STDOUT_FILENO, &ch, 1);
정도로 짧게 가능한데 뭔가 그러면 안되는 느낌임
참고로 폰으로 제작했음, 앱에서 unistd 그대로 지원하는것 보고 write 쓸려고 박은셈
3
8 comments
카락클라
05/23/25 ㄷㄷ 이 귀찮은걸
comi-soft
05/23/25 8바이트 이내에 된다는 것을 알았다면 그냥 unsigned long long을 쓸껄 그랬음
LTS
05/23/25 #include<unistd.h>
struct B{int i0:6;int i1:6;int i2:6;int i3:6;int i4:6;}s[]={
{0,1,2,3,4},{5,0,6,2,7},{0,8,9,10,11},{12,0,13,2,10},{14,15,3,16,17},{0,18,19,0,20},{15,21,0,0,0}};
#define A(o,x)(o.i##x)
#define B(o,i,d)d==i?A(o,i):
#define C(o,i)B(o,0,i)B(o,1,i)B(o,2,i)B(o,3,i)B(o,4,i)0
#define D(o,i)(C(o,i))
char*m="\xEC\xA0\x9C\xEA\xB2\x8C\x99\x20\x9D\xB4\xEB\x9F\xAC\x8B\x8A\x94\xB1\xB0\x97\x90\x9A\x3F";
main(){char c;int k=0;for(;k<32;k++)c=m[D(s[k/5],k%5)],write(1,&c,1);}
comi-soft
05/23/25 Edited 05/23/25두렵다
천목지성
05/25/25 #include<unistd.h>
char*m="ABCDEFAGCHAIJKLMANCKOPDQRASTAUPV\xEC\xA0\x9C\xEA\xB2\x8C\x99\x20\x9D\xB4\xEB\x9F\xAC\x8B\x8A\x94\xB1\xB0\x97\x90\x9A\x3F";
main(){for(int i=0;i<32;)write(1,m+m[i++]-33,1);}
그냥 재미삼아서 글자수 줄이는 방향으로 해봤는데 더 줄일 방법 모르겠음
Ghost
05/23/25 개추
Rohthis_
05/24/25 이게머노
C/C++
야매 C강의 2. 변수와 연산자
side-effect
11/03/25
1885
9
야매 C강의 2. 변수와 연산자
C/C++
side-effect
11/03/25 1885 9
C/C++
야매 C강의 1. 입출력
side-effect
11/02/25
1858
10
야매 C강의 1. 입출력
C/C++
side-effect
11/02/25 1858 10
C/C++
사칙연산이 없는 세계, 간단한 수식 연산기 ( 주의 )
comi-soft
06/14/25
3562
2
사칙연산이 없는 세계, 간단한 수식 연산기 ( 주의 )
C/C++
comi-soft
06/14/25 3562 2
C/C++
C++ 이거 머임?
얄랄랄루
06/11/25
3513
0
C++ 이거 머임?
C/C++
얄랄랄루
06/11/25 3513 0
C/C++
C 사칙 연산이 없는 세계에서 사칙연산 코드
comi-soft
06/06/25
4020
0
C 사칙 연산이 없는 세계에서 사칙연산 코드
C/C++
comi-soft
06/06/25 4020 0
C/C++
아 걍 다시 짜야겠다
Rohthis_
06/06/25
3668
0
아 걍 다시 짜야겠다
C/C++
Rohthis_
06/06/25 3668 0
C/C++
어떻게 하면 프로그래머를 괴롭히는 문제를 만들수 있을까?
hss9205
06/01/25
3652
0
어떻게 하면 프로그래머를 괴롭히는 문제를 만들수 있을까?
C/C++
hss9205
06/01/25 3652 0
C/C++
c list -> array function
comi-soft
06/01/25
2643
1
c list -> array function
C/C++
comi-soft
06/01/25 2643 1
C/C++
C const char* -> string, hello world
comi-soft
05/24/25
7219
0
C const char* -> string, hello world
C/C++
comi-soft
05/24/25 7219 0
C/C++
C 8byte hello world
comi-soft
05/23/25
7509
3
C 8byte hello world
C/C++
comi-soft
05/23/25 7509 3
C/C++
cpp hello world
hello_world
05/17/25
5392
0
cpp hello world
C/C++
hello_world
05/17/25 5392 0
C/C++
의외로 출력 결과가 같은 것
binary는 호남선
05/17/25
4770
1
의외로 출력 결과가 같은 것
C/C++
binary는 호남선
05/17/25 4770 1
s/turtleneckers
• 1,620 subscribers프로그래밍 서브입니다. 잡담, 문제 해결, 코드 리뷰(공지 필독)
Created 05/17/2025, 14:30:39
Rules
- 1. 기본 방임주의(절대 귀찮아서 그런 것 맞음)
- 2. 누가봐도 밴 당할법한 글 올리면 자를꺼임
- 3. 카테고리 지켜주면 좋겠지만 안지키면 안타까운거고