Trent said:
Quoth KuRcZ on or about 2004-11-17:
Hey, Im in grade 12 computer science, and i was going to learn C for
my final project, the only problem is,
I need to make something out of
C later on, and I have no idea's what I could make for my final
project, after I learn C. Any Idea's?
One interesting but simple[0] task is to try to write (some of) the
standard library functions.
[0] Well, I *say* simple. It largely depends on which functions you
choose to re-write.
These are my *.h files:
/* BEGIN str_ing.h */
#ifndef H_STR_ING
#define H_STR_ING
#include <stddef.h>
void *mem_set(void *s, int c, size_t n);
void *mem_cpy(void *s1, const void *s2, size_t n);
void *mem_move(void *s1, const void *s2, size_t n);
void *mem_chr(const void *s, int c, size_t n);
int mem_cmp(const void *s1, const void *s2, size_t n);
size_t str_len(const char *s);
char *str_cpy(char *s1, const char *s2);
char *str_ncpy(char *s1, const char *s2, size_t n);
char *str_cat(char *s1, const char *s2);
char *str_ncat(char *s1, const char *s2, size_t n);
char *str_chr(const char *s, int c);
char *str_rchr(const char *s, int c);
int str_cmp(const char *s1, const char *s2);
int str_ncmp(const char *s1, const char *s2, size_t n);
size_t str_spn(const char *s1, const char *s2);
size_t str_cspn(const char *s1, const char *s2);
char *str_pbrk(const char *s1, const char *s2);
char *str_str(const char *s1, const char *s2);
char *str_tok(char *s1, const char *s2);
/* non standard */
char *str_tok_r(char *s1, const char *s2, char **s3);
char *str_squeeze(char *s1, const char *s2);
char *str_rev(char *s);
#endif
/* END str_ing.h */
/* BEGIN ma_th.h */
#ifndef H_MA_TH
#define H_MA_TH
double sq_rt(double x);
double l_og(double x);
double l_og10(double x);
/* C99 */
double l_og2(double x);
#endif
/* END ma_th.h */
/* BEGIN std_lib.h */
#ifndef H_STD_LIB
#define H_STD_LIB
#include <stddef.h>
/*
** a_toi does what atoi does in the C locale only.
*/
int a_toi(const char *nptr);
void q_sort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
/*
** As a quality of implementation issue,
** b_search finds the first occurence of the key in the array.
*/
void *b_search(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
/* non standard */
void itoa_1(int n, char *s);
void itoa_2(int n, char *s);
void bit_str(char *s1, const void *s2, size_t n);
unsigned char bit_rev(unsigned char byte);
#endif
/* END std_lib.h */
/* BEGIN c_type.h */
#ifndef H_C_TYPE
#define H_C_TYPE
int is_digit(int c);
/*
** The following functions do what the corresponding
** standard C functions do in the C locale only.
*/
int is_space(int c);
int is_upper(int c);
int is_lower(int c);
int is_alpha(int c);
int is_alnum(int c);
int to_upper(int c);
int to_lower(int c);
#endif
/* END c_type.h */
/* BEGIN std_io.h */
#ifndef H_STD_IO
#define H_STD_IO
#include <stdio.h>
/*
** Only 5 features from stdio.h,
** are used in std_io.h and std_io.c:
**
** 1 putc(c, stream)
** 2 stdout
** 3 FILE
** 4 EOF
** 5 int ferror(FILE *stream);
*/
#define put_c(c, stream) (putc((c), (stream)))
#define put_char(c) (put_c((c), stdout))
int fput_c(int c, FILE *stream);
int (put_c)(int c, FILE *stream);
int (put_char)(int c);
int fput_s(const char *s, FILE *stream);
int put_s(const char *s);
int min_printf(const char *s, ...);
/*
** Only 5 different conversion specifiers
** are supported by min_printf: c d s u %
** and no fancy stuff.
*/
#endif
/* END std_io.h */