Skip to content

Instantly share code, notes, and snippets.

@duyet
Last active August 29, 2015 14:16
Show Gist options
  • Save duyet/8b61eb8eda7b60ac6cb1 to your computer and use it in GitHub Desktop.
Save duyet/8b61eb8eda7b60ac6cb1 to your computer and use it in GitHub Desktop.
/**
* Van-Duyet Le
*
* Data file: av.dd (http://blackberryvietnam.net/threads/du-lieu-tu-dien-cho-ung-dung-ddict.897)
*/
#include <stdio.h>
//#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define MAX_WORD 1000
int main() {
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("av.dd", "rt");
if (fp == NULL) exit(EXIT_FAILURE);
int count = 0;
char *englishArray[MAX_WORD]; // English Array
while ((read = getline(&line, &len, fp)) != -1 && count < MAX_WORD) {
char *tokens;
tokens = strtok(line, "###");
if (tokens) {
englishArray[count++] = (tokens);
free(tokens);
}
}
fclose(fp);
if (line) free(line);
for (int i = 0; i < count; i++) {
printf("%s\n", englishArray[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment