Hey, I'm trying to write a program that teaches you basic Danish vocabulary. Anyway, I originally had an array of structs with const chars for the dan word and eng word like so...
So, then I came up with this crazy idea... I want to read the values I'm assigning to each const string from a file of hex nummers. Here's the file, called testfire.dat:
}ords[ORDNUMMER];//ORDNUMMER defined earlier
//some other stuff...
ords.dan="some danish word";
ords.eng="some english word";
//and so on
61 6c 6d 69 6e 64 65 6c 69 67 65 64 00000000 //Almindeliged
6f 72 64 69 6e 61 72 79 2c 20 6e 6f 72 6d 61 6c 00000000 //Ordinary, normal
61 72 62 65 6a 64 65 00000000 //arbejde
77 6f 72 6b 00000000 //work
62 65 73 c3 b8 67 65 00000000 //besøge
I put C style comments in there so you can see what the values mean. They're not actually in the file. (Also, the 00000000 signifies the end of a word, as you'll see later)
Please note I'm assuming UTF-8 encoding. The problem I'm having is with the last line, the ø character, hex c3 b8. I get a segmentation fault when I run it in the command line. It's interesting, because when I run it in gdb, I don't get a seg fault, but it skips over the last e in besøge:
Oh! Almost forgot the source...
Starting program: /home/webmaster/Downloads/Tests/a.out
Program exited normally.
It may or may not have been obvious, but I honestly don't know a thing about computer memory. So... what's going on?
fscanf(mFile, "%x", &ords[i].dan[i]);