Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "stringtable.h"
- struct stringnode{
- hashcode_t key;
- cstring value;
- };
- struct stringtable{
- size_t dim;
- size_t numEntries;
- stringnode_ref *nodes;
- };
- stringtable_ref new_stringtable(){
- size_t index = 0;
- stringtable_ref sTable = malloc(sizeof(struct stringtable));
- sTable->dim = 31;
- sTable->numEntries;
- sTable->nodes = malloc(31 * sizeof(struct stringnode));
- for( index = 0; index < 31; index++ ){
- sTable->nodes[index]->key = 0;
- sTable->nodes[index]->value = NULL;
- }
- return sTable;
- }
- #ifndef __STRINGTABLE_H__
- #define __STRINGTABLE_H__
- #include <stdlib.h>
- #include <inttypes.h>
- typedef char *cstring;
- typedef uint32_t hashcode_t;
- typedef stringtable *stringtable_ref;
- typedef stringnode *stringnode_ref;
- stringtable_ref new_stringtable();
- #endif // __STRINGTABLE_H__
- #include <stdlib.h>
- #include <stdio.h>
- #include "stringtable.h"
- int main( int argc, char **argv ){
- stringtable_ref table = new_stringtable();
- return EXIT_SUCCESS;
- }
- gcc -g -O0 -Wall -Wextra -std=gnu99 -c stringtable.c
- gcc -g -O0 -Wall -Wextra -std=gnu99 -c oc.c
- gcc -g -O0 -Wall -Wextra -std=gnu99 -o oc stringtable.o oc.o
- sTable->nodes = malloc(31 * sizeof(struct stringnode));
- for( index = 0; index < 31; index++ ){
- sTable->nodes[index]->key = 0;
- sTable->nodes[index] = malloc(sizeof(*(sTable->nodes[index])));
- struct stringtable{
- size_t dim;
- size_t numEntries;
- stringnode_ref nodes;
- };
- sTable->nodes[index].key = 0;
- sTable->nodes[index].value = NULL;
- #include <stdlib.h>
- typedef char *cstring;
- struct stringnode{
- int key;
- cstring value;
- };
- typedef struct stringnode *stringnode_ref;
- struct stringtable{
- size_t dim;
- size_t numEntries;
- stringnode_ref nodes;
- };
- typedef struct stringtable *stringtable_ref;
- stringtable_ref new_stringtable(){
- size_t index = 0;
- stringtable_ref sTable = malloc(sizeof( *sTable ) ) ;
- sTable->dim = 31;
- sTable->nodes = malloc(31 * sizeof( *sTable->nodes ) ) ;
- for( index = 0; index < 31; index++ ){
- sTable->nodes[index].key = 0;
- sTable->nodes[index].value = NULL;
- }
- return sTable;
- }
- int main(int argc, char *argv[]) {
- stringtable_ref table = new_stringtable();
- exit( EXIT_SUCCESS ) ;
- }
- :~/tmp$ gcc -g -O0 -Wall -Wextra -std=gnu99 -c stringtable.c
- In file included from stringtable.c:2:
- stringtable.h:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
- stringtable.h:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
- stringtable.h:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘new_stringtable’
- stringtable.c:12: error: expected specifier-qualifier-list before ‘stringnode_ref’
- stringtable.c:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘new_stringtable’
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement