cleaning things up a bit

This commit is contained in:
Dan Buch
2011-06-16 21:46:56 -04:00
parent e026dabefb
commit 731e1002cd
10 changed files with 39 additions and 7 deletions

View File

@@ -0,0 +1,23 @@
#include <stdio.h>
int array[] = {23, 34, 12, 17, 204, 99, 16};
#define TOTAL_ELEMENTS sizeof(array) / sizeof(array[0])
int main()
{
int d;
#ifdef DEBUG
printf("sizeof(array) = %d\n", TOTAL_ELEMENTS);
#endif
for (d = 0; d < TOTAL_ELEMENTS ; d++)
printf("%d\n", array[d]);
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/

View File

@@ -0,0 +1,20 @@
/**
* :author: Dan Buch (daniel.buch@gmail.com)
*/
#include <stdio.h>
int main()
{
int i = 1;
do
{
printf("%d\n", i);
} while(++i < 15);
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/

View File

@@ -0,0 +1,22 @@
/**
* :author: Dan Buch (daniel.buch@gmail.com)
*/
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("(Hit ^C to stop the madness.)\n");
while(1)
{
fprintf(stdout, "hello-out ");
fprintf(stderr, "hello-err ");
sleep(1);
}
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/

View File

@@ -0,0 +1,23 @@
/**
* :author: Dan Buch (daniel.buch@gmail.com)
*/
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("This time we'll include \\n!\n");
printf("(Hit ^C to stop the madness.)\n");
while(1)
{
fprintf(stdout, "hello-out\n");
fprintf(stderr, "hello-err\n");
sleep(1);
}
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/

View File

@@ -0,0 +1,24 @@
/**
* :author: Dan Buch (daniel.buch@gmail.com)
*/
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("This time we'll flush stdout!\n");
printf("(Hit ^C to stop the madness.)\n");
while(1)
{
fprintf(stdout, "hello-out ");
fprintf(stderr, "hello-err ");
fflush(stdout);
sleep(1);
}
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/

View File

@@ -0,0 +1,19 @@
/**
* :author: Dan Buch (daniel.buch@gmail.com)
*/
#include <stdio.h>
#define f(a, b) a##b
#define g(a) #a
#define h(a) g(a)
int main()
{
printf("%s\n", h(f(1, 2)));
printf("%s\n", g(f(1, 2)));
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/

14
gowrikumar/src/Makefile Normal file
View File

@@ -0,0 +1,14 @@
# puzzles from http://www.gowrikumar.com/c/
BINDIR := ../bin
ALL_BIN := $(patsubst %.c,$(BINDIR)/%,$(wildcard *.c))
$(BINDIR)/%: %.c
$(CC) -o $@ $<
all: $(ALL_BIN)
.PHONY: all