Dictionary into a 2d Char Array... Problems.
Hi, i'm new, a uni student in the UK looking for some help on a uni assignment.
I have had the work marked off with a provisional grade for if it functions correctly, but we've now got the weekend to finish the code off, make it all neat etc, and hand it in on monday.
Thus, i need to rip out the hard-coded Dictionary, and get it to read from file.
And this is where i come unstuck. I've tried For Loops (Not good, because the column length might be set to 10, but if the word is FRED, it's not going to stop going once it's hit D), and so far onto while loops, and i just can't get the blasted thing working.
Here's the code (please don't laugh, i'm a 2nd year student and this is my first time with C, i'm normally a VB.NET student)
I get the theory of what i need to do.
if (filepointer == NULL)
printf("File not found");
while (ch != EOF)
printf("Loading Words into Array\n");
printf("Dictionary %d: ", x);
while (ch != '.')
ch = getc(filepointer);
Dictionary[x][y] = ch;
Dictionary[x][y] = '\0';
Insert first letter from file into the first column in the array. Increment array and insert next letter, keep going until you hit a delimiter (.) or \n depending. (i'd rather have a list so that the text file is neat, but if i need to use delimiters, so be it). Once you hit the delimiter, you then come out of the inner loop, increment the first part of the Dictionary, and go back into the loop. In theory, you eventually end up with a nice shiny list of words.
But it doesn't work.
If anyone can give advice, and if possible, an explanation of why not only mine doesn't work, but how to get this working (because this seems a rather unwieldy way of getting strings into an array), i would be grateful. I'm not looking for a straight answer (although, it would be nice?) just enough pointers (heh) and hints so i can work it out for myself.
I did google this (c file to 2d array) which lead me here, but the google in question was to someone getting ints into a 2d int array, using commands specific to that.
Thanks in advance. Hopefully once this degree is out of the way i can settle down and explore C as a language. I do like programming (i know, they all say that), i just never seem to have the time to enjoy what i'm doing. It's always "rush rush assignments, portfolios, assessments, end of module, do new stuff".