Skip to content
Snippets Groups Projects
Commit d54baf28 authored by 이소현's avatar 이소현
Browse files

lec08

parent b70f0272
Branches
No related tags found
No related merge requests found
#include <stdio.h>
int add(int *a, int *b, int *c)
{
*c = *a + *b;
}
int main()
{
int a = 100;
int b = 200;
int c = 999;
// int * == long long
fprintf(stdout, "%d : %lld %llx\n", a,(long long) &a,(long long) &a);
fprintf(stdout, "%d : %lld %llx\n", b, (long long)&b, (long long)&b);
add(&a, &b ,&c);
//c = a+b
fprintf(stdout, "%s %d : %d\n",__FILE__, __LINE__,c);
fprintf(stdout, "%s %d : %d\n",__FILE__, __LINE__,c);
fprintf(stdout, "%s %d : %d\n",__FILE__, __LINE__,c);
#define ERR_DATA 2000
#if ERR_DATA > 1000
#error 1024
#else
#warning ERR_DATA
#endif
fprintf(stdout, "%s %d : %d",__FILE__, __LINE__,c);
}
File added
.file "hello.c"
# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "hello.c"
int add(int *a, int *b, int *c)
{
*c = *a + *b;
}
int main()
{
const int a = 100;
int b = 200;
long long c = 999;
fprintf(stdout, "%d : %lld %llx\n", a, &a, &a);
fprintf(stdout, "%d : %lld %llx\n", b, &b, &b);
add(&a, &b ,&c);
fprintf(stdout, "%d : %lld %llx\n", c, &c, &c);
fprintf(stdout, "%d : %lld %llx\n", c, &c+1, &c+1);
fprintf(stdout, "%d : %lld %llx\n", c, &c+2, &c+2);
}
File added
.file "hellocpp.c"
#define HE HI
#define LLO _THERE
#define HELLO "HI THERE"
#define CAT(a,b) a##b
#define XCAT(a,b) CAT(a,b)
#define CALL(fn) fn(HE,LLO)
CAT(HE,LLO) // "HI THERE", because concatenation occurs before normal expansion
XCAT(HE,LLO) // HI_THERE, because the tokens originating from parameters ("HE" and "LLO") are expanded first
CALL(CAT) // "HI THERE", because parameters are expanded first
#define sq(a) a*a
sq(B)
#define sq(a) aaa
sq(C)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment