Hallo allemaal.
Ik heb een probleem. Ik heb vandaag voor de lol eens geprobeerd om mijn eigen header file voor C te schrijven. Het betreffen gewoon wat functies die in string.h teruggevonden kunnen worden. Hier is de broncode:
van het C programma dat deze header gebruikt :
#include <C:\Documents and Settings\\My Documents\TestC\mem_functions.h>
#include <stdio.h>
int main ()
{
short i;
char zin[6] = "Hallo";
int getallen1[5] = { 5, 22, 3, 14, 6 }, getallen2[5];
printf ( "%d", strlen ( zin ) );
memmove ( getallen2, getallen1, 5 );
for ( i = 0; i < 5; i++ )
printf ( "%d \n", getallen2[i] );
memsetw ( getallen2, 6, 5 );
for ( i = 0; i < 5; i++ )
printf ( "%d \n", getallen2[i] );
getchar();
return 0;
}
van de header :
#ifndef mem_functions.h
#define mem_functions.h
#endif
int i;
void memset ( char * mem_block, unsigned char val, int sizeofblock )
for ( i = 0; i < sizeofblock; i++ )
mem_block[i] = val;
void memsetw ( char * mem_block, unsigned short val, int sizeofblock )
for ( i = 0; i < sizeofblock; i++ )
mem_block[i] = val;
int * memmove ( int * dest, int * src, int sizeofblock )
for ( i = sizeofblock; i > 0; i++ )
dest[i] = src[i];
int * memcpy ( int * dest, int * src, int sizeofblock )
for ( i = 0; i < sizeofblock; i++ )
dest[i] = src[i];
int strlen ( char * string )
{
for ( i = 0; string[i] != '\0'; i++ )
return i;
}
Dit zijn alle foutmeldingen die ik krijg :
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|1|warning: extra tokens at end of #ifndef directive|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|3|warning: ISO C requires whitespace after the macro name|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|10|error: expected initializer before "for"|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|10|error: expected constructor, destructor, or type conversion before '<' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|10|error: expected constructor, destructor, or type conversion before '++' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|13|error: expected initializer before "for"|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|13|error: expected constructor, destructor, or type conversion before '<' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|13|error: expected constructor, destructor, or type conversion before '++' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|16|error: expected initializer before "for"|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|16|error: expected constructor, destructor, or type conversion before '>' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|16|error: expected constructor, destructor, or type conversion before '++' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|19|error: expected initializer before "for"|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|19|error: expected constructor, destructor, or type conversion before '<' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|19|error: expected constructor, destructor, or type conversion before '++' token|
C:\Documents and Settings\\My Documents\TestC\mem_functions.h|25|warning: no newline at end of file|
C:\Documents and Settings\\My Documents\TestC\testmemfuncs.c||In function `int main()':|
C:\Documents and Settings\\My Documents\TestC\testmemfuncs.c|10|error: `memmove' was not declared in this scope|
C:\Documents and Settings\\My Documents\TestC\testmemfuncs.c|13|error: `memsetw' was not declared in this scope|
||=== Build finished: 14 errors, 3 warnings ===|
Ik hoop dat iemand me wat uitleg over de foutmeldingen kan geven. Alvast bedankt !