LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-20-2005, 05:12 AM   #1
cigarstub
Member
 
Registered: Sep 2005
Posts: 145

Rep: Reputation: 15
Learn English with a C program


I'd like to write a program that keeps track of English works that I have learned so that I can do a self-test periodically. Could you tell me anything that can be changed in the source, for exemple the coding style or a more efficient syntax. Sorry about uncompleted command it's due to the lack of knowledge, just if you don't mind to suggest some alternatives to complete it.
Code:
#include <stdio.h>
enter_new_word() {
	char s[20];
	FILE *f;
	/*Open the file for appending*/
	/*If user enter "test" then go to the next function*/
	printf("Enter a new word: ");
	/*Eeceive the work ? */
	/*Append the word in the file*/
	/*Close the file*/
	
vocabulary_test() {
	FILE *f;
	char s[20];	
	/*Open f for reading*/
	while (EOF == 0) {
		/*Scan the word to s*/
		printf("\nDo you remember the definitions of %s\n",s);
		getch();
	}
}

main() {
	enter_new_word();
}
 
Old 09-20-2005, 11:53 AM   #2
orgcandman
Member
 
Registered: May 2002
Location: dracut MA
Distribution: Ubuntu; PNE-LE; LFS (no book)
Posts: 594

Rep: Reputation: 102Reputation: 102
Why not store the whole thing in the file?

I'm thinking something like this:

typedef struct t_dict_ent {
int w_len;
int d_len;
char *word;
char *defin;
} dictent;

then do:

dictent *pentry = malloc(sizeof(dictent)+strlen("test")+strlen("this is a test"));
entry->w_len=strlen("test");
entry->d_len=strlen("this is a test");
strcpy(entry->word, "test");
strcpy(entry->defin, "this is a test");

then you can fwrite pentry. when you read it in, you'll get the word, and the definition.

just a suggestion
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Way to use a good free English to English Dictionary linbose Linux - Software 6 06-03-2009 10:25 PM
i want to learn to program... trey85stang Programming 13 01-07-2005 01:22 PM
Can I have english menu with chinese/english/spanish input? codec Linux - General 9 10-04-2003 07:18 PM
Want to learn to Program Tenover Linux - Newbie 13 03-28-2003 02:38 PM
any programmers who had to fight hard to learn to program? Flotilla Programming 14 01-21-2003 06:49 AM


All times are GMT -5. The time now is 11:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration