Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctype.h>
- struct FParseSymbol
- {
- int Value;
- char Sym[80];
- };
- union FParseToken
- {
- int val;
- double fval;
- char sym[80];
- char string[80];
- FParseSymbol *symval;
- };
- static FParseSymbol symbols[10];
- bool FindSym (char *sym, FParseSymbol **val)
- {
- // Remove loop or if here to fix
- for(unsigned i=0;i<10; i++)
- {
- if (strcmp (symbols[i].Sym, sym) == 0)
- {
- *val = &symbols[i];
- return true;
- }
- }
- return false;
- }
- int GetToken (char *&sourcep, FParseToken *yylval)
- {
- char token[80];
- int toksize;
- memset(token, 'a', 10);
- toksize = 10;
- token[toksize] = 0;
- // Remove this if line to fix
- if (FindSym (token, &yylval->symval)) return 0;
- strcpy (yylval->sym, token);
- // Replacing above strcpy with this works
- //memcpy(yylval->sym, token, 80);
- return 0;
- }
- int main()
- {
- char* test = NULL;
- FParseToken sym;
- GetToken(test, &sym);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement