diff --git a/C-RK/C-RK-Week2/C-RK-Week2.vcxproj b/C-RK/C-RK-Week2/C-RK-Week2.vcxproj new file mode 100644 index 0000000..171bbe4 --- /dev/null +++ b/C-RK/C-RK-Week2/C-RK-Week2.vcxproj @@ -0,0 +1,149 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B1FF6384-6F00-4702-9915-6BAC8DC696EA} + Win32Proj + CRKWeek2 + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/C-RK/C-RK-Week2/C-RK-Week2.vcxproj.filters b/C-RK/C-RK-Week2/C-RK-Week2.vcxproj.filters new file mode 100644 index 0000000..6a1782f --- /dev/null +++ b/C-RK/C-RK-Week2/C-RK-Week2.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file diff --git a/C-RK/C-RK-Week2/Makefile b/C-RK/C-RK-Week2/Makefile new file mode 100644 index 0000000..c72c8cf --- /dev/null +++ b/C-RK/C-RK-Week2/Makefile @@ -0,0 +1,28 @@ +# Voorbeeld Makefile +# +# @ Diederich Kroeske, 2011 +# + +CC = gcc +#CC = avr-gcc + +TARGET = llexample +CFLAGS = -Wall -O2 + +all : $(TARGET) + +llist.o : llist.c llist.h + echo $@ + $(CC) -c llist.c $(CFLAGS) + +main.o : main.c + $(CC) -c main.c $(CFLAGS) + +$(TARGET): main.o llist.o + $(CC) main.o llist.o $(CFLAGS) -o $(TARGET) + +clean : + rm -f $(TARGET) main.o llist.o + +info : + @echo "$(CC) using $(CFLAGS)" diff --git a/C-RK/C-RK-Week2/llist.c b/C-RK/C-RK-Week2/llist.c new file mode 100644 index 0000000..92dffbe --- /dev/null +++ b/C-RK/C-RK-Week2/llist.c @@ -0,0 +1,55 @@ +#include "stdlib.h" +#include "stdio.h" +#include "llist.h" + + +static struct node *pHead = NULL; + +void init() +{ + pHead = NULL; + +} + +/* + * Aan de voorkant invoegen + */ +int add(int data) +{ + struct node *pn = (struct node*)malloc(sizeof(struct node)); + + if(NULL == pn) + { + printf("Out of memory ..."); + } + else + { + if(NULL == pHead) + { + pn->data = data; + pn->next = NULL; + pHead = pn; + } + else + { + pn->data = data; + pn->next = pHead; + pHead = pn; + } + } + + return 1; +} + +void show() +{ + struct node *p = pHead; + int nr = 0; + + for( ; NULL != p->next ; p = p->next ) + { + printf("node nr: %d heeft data [%d]\n",nr++,p->data); + } +} + + diff --git a/C-RK/C-RK-Week2/llist.h b/C-RK/C-RK-Week2/llist.h new file mode 100644 index 0000000..c65d6a8 --- /dev/null +++ b/C-RK/C-RK-Week2/llist.h @@ -0,0 +1,14 @@ +#ifndef LLIST_DEF +#define LLIST_DEF + +struct node +{ + int data; + struct node *next; +}; + +void init(); +int add(int data); +void show(); + +#endif diff --git a/C-RK/C-RK-Week2/main.c b/C-RK/C-RK-Week2/main.c new file mode 100644 index 0000000..3c8d611 --- /dev/null +++ b/C-RK/C-RK-Week2/main.c @@ -0,0 +1,17 @@ +#include +#include "llist.h" + +int main() +{ + int idx; + + init(); + + for(idx = 0; idx < 10; idx++) + { + add(idx); + } + show(); + + return 1; +}