For my final project, I decided to write a C program that conjugates German verbs. Overall, it's gone very, very well, and the program can handle quite a bit. Everything was working until I implemented a feature to deal with prefixed verbs. The feature essentially removes the prefix and passes the rest of the verb onto the remainder of the program. The prefix is then added back in at the end.
However, a design choice very, VERY early on has reared it's ugly head.
I have the program split across several different .c
files with a single header file linking it all together. The main purpose of those extra files is to clean up the main file and pass back the various verb forms required. But when I declared, for example, the conjugated verb form in the file that has all the functions dealing with conjugation, clang
gave me an error that the conjugated verb variable declared in that second file was not, in fact, declared. I dealt with this by, instead, declaring it in the header, but because it's a string, I needed to give it a size. That early on, there was no way I could determine how big it needed to be, so I declared it as char conjverb[1]
. Later, I was forced to do the same with the prefix variable, but now I'm faced with the problem I was hoping I would never see: my prefix variable is being overwritten by conjverb
.
Is there some other way I can deal with these string declarations in my program to declare them when I need them instead of declaring them WAY in advance? I need the variables to be able to move from function to function and from file to file.
Thanks in advance!