34 lines
760 B
C
34 lines
760 B
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
// int strncmp(const char *str1, const char *str2, size_t n)
|
||
|
// returns 0 if n fist characters are equal
|
||
|
|
||
|
// char *strcat(char *dest, const char *src)
|
||
|
// appeds src to dest. Make sure that dest is big enough. Returns pointer to dest.
|
||
|
|
||
|
char *ConcatPre(char *Buffer, char *WordArray[], int Count)
|
||
|
{
|
||
|
// TODO: Implement this function such that all words beginning with "pre"
|
||
|
// will be concatenated and returned.
|
||
|
return Buffer;
|
||
|
}
|
||
|
|
||
|
int main(int argc, const char *argv[])
|
||
|
{
|
||
|
char Buffer[32];
|
||
|
|
||
|
char *Words[] =
|
||
|
{
|
||
|
"precompiler ",
|
||
|
"postfix ",
|
||
|
"preprocessor ",
|
||
|
"postprocessing ",
|
||
|
"prefix "
|
||
|
};
|
||
|
|
||
|
ConcatPre(Buffer, Words, 5);
|
||
|
|
||
|
printf("The buffer contains:\n%s \nand has length %d", Buffer, (int)strlen(Buffer));
|
||
|
}
|