C const char* -> string, hello world
그냥 웹에서 타자 작성
#include <unistd.h>
#define tem_con(T, name) \
typedef struct { \
T* d; unsigned long long int size; \
} name
tem_con(char, string);
#define create_string(c_str) \
(string){c_str, sizeof(c_str)}
#define _for_(T, val, arr) \
for(T* val = arr.d; val != (char*)arr.d + arr.size; val++)
int main(int argc, char** argv) {
string str = create_string("hello_world");
_for_(char, it, str ) {
write(1, it, 1);
}
return 0;
}
#include <unistd.h>
#define template_one_container(T, name) \
struct { \
T* d; \
unsigned long long int size; \
} name
#define template_container(T, name) \
typedef template_one_container(T, name)
template_container(char, std_string);
#define create_string(c_str) \
(std_string){ c_str, sizeof(c_str) }
#define create_array(format) \
{ format, sizeof(format) }
#define define_array(T, name, count) \
T __CA__##name[count]; \
template_one_container(T, name) = \
create_array(__CA__##name)
#define _for_(T, val, arr) \
for(T* val = arr.d; (char*)val != (char*)(arr.d) + arr.size; val++ )
int toString(int number, std_string str)
{
char* str_ptr = str.d+str.size;
char* write_ptr = str.d;
if(number == 0) {
str.d[0] = '0';
return 1;
} else if(number < 0) {
*(write_ptr++) = '-';
number = -number; // 최소값은 저는 모르는거에욧
}
while(--str_ptr != str.d -1 && number != 0)
*str_ptr = number % 10 + '0', number /= 10;
while(str_ptr != str.d+str.size)
*(write_ptr++) = *(str_ptr++);
*(write_ptr++) = '\0';
return (int)(write_ptr - str.d);
}
int main(int argc, char** argv)
{
std_string string = create_string("hello world\n");
define_array(int, intInArray, string.size);
char* str_ptr = string.d;
_for_(int, it, intInArray) {
if(str_ptr == string.d + string.size) break;
*it = *(str_ptr++);
}
char __buffer__[32] = {0};
std_string buffer = create_string(__buffer__);
_for_(int, it, intInArray) {
int size = toString(*it, buffer);
buffer.d[size++] = ' ';
write(1, buffer.d, size);
}
return 0;
}숫자 hello world
0
0 comments
C/C++
야매 C강의 2. 변수와 연산자
side-effect
11/03/25
1884
9
야매 C강의 2. 변수와 연산자
C/C++
side-effect
11/03/25 1884 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
3561
2
사칙연산이 없는 세계, 간단한 수식 연산기 ( 주의 )
C/C++
comi-soft
06/14/25 3561 2
C/C++
C++ 이거 머임?
얄랄랄루
06/11/25
3511
0
C++ 이거 머임?
C/C++
얄랄랄루
06/11/25 3511 0
C/C++
C 사칙 연산이 없는 세계에서 사칙연산 코드
comi-soft
06/06/25
4019
0
C 사칙 연산이 없는 세계에서 사칙연산 코드
C/C++
comi-soft
06/06/25 4019 0
C/C++
아 걍 다시 짜야겠다
Rohthis_
06/06/25
3666
0
아 걍 다시 짜야겠다
C/C++
Rohthis_
06/06/25 3666 0
C/C++
어떻게 하면 프로그래머를 괴롭히는 문제를 만들수 있을까?
hss9205
06/01/25
3650
0
어떻게 하면 프로그래머를 괴롭히는 문제를 만들수 있을까?
C/C++
hss9205
06/01/25 3650 0
C/C++
c list -> array function
comi-soft
06/01/25
2640
1
c list -> array function
C/C++
comi-soft
06/01/25 2640 1
C/C++
C const char* -> string, hello world
comi-soft
05/24/25
7218
0
C const char* -> string, hello world
C/C++
comi-soft
05/24/25 7218 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
5391
0
cpp hello world
C/C++
hello_world
05/17/25 5391 0
C/C++
의외로 출력 결과가 같은 것
binary는 호남선
05/17/25
4769
1
의외로 출력 결과가 같은 것
C/C++
binary는 호남선
05/17/25 4769 1
s/turtleneckers
• 1,620 subscribers프로그래밍 서브입니다. 잡담, 문제 해결, 코드 리뷰(공지 필독)
Created 05/17/2025, 14:30:39
Rules
- 1. 기본 방임주의(절대 귀찮아서 그런 것 맞음)
- 2. 누가봐도 밴 당할법한 글 올리면 자를꺼임
- 3. 카테고리 지켜주면 좋겠지만 안지키면 안타까운거고