Skip to content
Snippets Groups Projects
Commit 835a4040 authored by Nayoung Kim's avatar Nayoung Kim
Browse files

add testcode

parent 7e8c3dc7
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,9 @@ void addPointer(int *a, int *b, int *c)
int addValue(int a, int b, int c)
{
fprintf(stdout, "In addValue A %d : %lld %llx\n", a, &a, &a);
fprintf(stdout, "In addValue B %d : %lld %llx\n", b, &b, &b);
fprintf(stdout, "In addValue C %d : %lld %llx\n", c, &c, &c);
c = a + b;
fprintf(stdout, "In addValue A %d : %lld %llx\n", a, &a, &a);
fprintf(stdout, "In addValue B %d : %lld %llx\n", b, &b, &b);
......
#include <stdio.h>
#define DEBUG
#define INTRO
int main() {
#ifdef DEBUG // #ifdef는 위에서 매크로가 선언된 경우 내부 코드가 실행됨
printf("Debug : %s \t %s \t %s \t %d \n", __DATE__, __TIME__, __FILE__, __LINE__);
#endif
char name[] = "Nayoung";
int age = 21;
#ifndef INTRO // #ifndef는 위에서 매크로가 선언되지 않은 경우 내부 코드를 실행함
printf("Name : %s \t Age : %d \n", name, age);
#endif
return 0;
}
#include <stdio.h>
#define DEBUG_LEVEL 2
int main()
{
#if DEBUG_LEVEL >= 2
printf("Debug Level 2 \n");
#endif
return 0;
}
......@@ -3,6 +3,7 @@
#define FN_SUB 1
#define FN_MUL 2
#define FN_DIV 3
#define FN_ERR 4
void add(int *a, int *b, int *c)
{ *c = *a + *b; }
......@@ -16,15 +17,21 @@ void mul(int *a, int *b, int *c)
void div(int *a, int *b, int *c)
{ *c = (*a) / (*b); }
void err(int *a, int *b, int *c)
{
*c = ' ';
fprintf(stdout, "wrong input\n");
}
int main()
{
int a, b, c;
char ch;
int op = FN_ADD; // default is add
int op = FN_ERR; // default is err
scanf("%d %c %d", &a, &ch, &b);
void (*fp[4])(int *, int *, int *) = {add, sub, mul, div};
void (*fp[5])(int *, int *, int *) = {add, sub, mul, div, err};
switch (ch)
{
case '+':
......@@ -40,14 +47,13 @@ int main()
op = FN_DIV;
break;
default :
op = FN_ADD;
op = FN_ERR;
break;
}
fp[op](&a,&b,&c);
if(op == 4){
return 0;
}
fprintf(stdout, "%d \n", c);
// int const * p = &a;
// int * const q = &a;
}
#include "func.h"
#define __FUNC_ 0
#define FUNCTION_NEGATIVE
extern int fun1(int x);
extern int fun2(int x);
#if __FUNC_ == 0
int func1(int a)
......@@ -21,4 +19,3 @@ int func3(int a)
return DF(a+2)*20;
}
#endif
File deleted
#include <stdio.h>
#define FUNCTION_NEGATIVE 1
#include "func.h"
#define __FUNC_
#define __FUNC_ 0
int main()
{
printf("func1 %d %d\n", func1(100), DF(10));// func 110 100
......@@ -9,4 +9,3 @@ int main()
printf("func2 %d %d\n", func2(100), DF(10));// func 110 100
}
File added
#include <stdio.h>
#define DECLARE_STRUCT_TYPE(name) typedef struct name##_s name##_t
int main(){
#define str(s) #s
printf("%s \n", str(1+2));
#define ST(a) #a
char name[] = ST(Nayoung);
printf("%s \n", name);
DECLARE_STRUCT_TYPE(g_object);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment