Subject: Need help with c! Approved: clc AT plethora DOT net Content-Transfer-encoding: 7bit From: Mohanaraj Gopala Krishnan Organization: Unconfigured X-Accept-language: en Content-Type: text/plain; charset=us-ascii Lines: 349 Mime-Version: 1.0 Newsgroups: comp.os.msdos.djgpp,comp.lang.c.moderated Message-ID: X-Mailer: Mozilla 4.5 [en] (Win98; I) Originator: clcm AT plethora DOT net (comp.lang.c.moderated) Date: Sun, 17 Jan 1999 18:55:49 GMT NNTP-Posting-Host: 205.166.146.1 X-Trace: ptah.visi.com 916599349 205.166.146.1 (Sun, 17 Jan 1999 12:55:49 CDT) NNTP-Posting-Date: Sun, 17 Jan 1999 12:55:49 CDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi, I use djgpp and am kinda new to c. I am not sure if this is the right group to post this but I am very much hoping I can get help here. I have this source code which has no problem when compiling and producing the exe. But if i trace through it there is a particular function which is problematic. The function is as follows, it a file reading function... #include #include static FILE *fptr; static int recsize; void open_file(int * pages_done, int array_size); void close_file(int * pages_done, int array_size); void write_file(char * strpointer, int page_size, int page_no); void open_file(int * pages_done, int array_size) { int i=0; if((fptr=fopen("chapter.dat", "r")) !=NULL) { fseek(fptr,0L,SEEK_SET); for(i=0;i void menu(void); void printmenu(void); void FUNCT_new_page(void); void main() { /*PAGE output_page;*/ menu(); /*read_page((char *)&output_page); display_page(output_page);*/ return 0; } void menu(void) { char choice; int done=0; do { printmenu(); choice=getch(); switch(choice) { case 'n': FUNCT_new_page(); break; case 'c': printf("This will continue the editing of an existing chapter"); break; case 'p': printf("This will play a chapter"); break; case 'q': printf("This will quit this menu"); done=1; break; default: break; } }while(!done); } void printmenu(void) { printf("a saradiya solutions product\n\n\n"); printf("\t n--start new chapter\n"); printf("\t c--continue editing existing chapter\n"); printf("\t p--play a chapter file\n"); printf("\t q--quit this thing"); printf("\n\n"); printf("\t enter yer choice "); } THIS IS THE SOURCE WHICH DEALS WITH THE PAGE CHARACTERISTICS AND FUNCTIONS #include #define STORY_LENGTH 300 #define OPTION_1_LENGTH 50 #define OPTION_2_LENGTH 50 #define MAN_ARRAY_SIZE 100 typedef struct page { int no; char option_1[OPTION_1_LENGTH]; int link_1; char option_2[OPTION_2_LENGTH]; int link_2; char story[STORY_LENGTH]; } PAGE; /*will accept page number next also include the size of the structure*/ /*void read_page(char* strpointer);*/ /*will return link choice next time*/ /*void display_page(PAGE VAR_page_displaying); /*this function receives nothinbg it just fills up a structure and returns it*/ /*PAGE input_page(void); */ /*2nd level implementation */ void FUNCT_new_page(void); /*file access stuff in file.c*/ void open_file(int * pages_done, int array_size); void close_file(int * pages_done, int array_size); void write_file(char * strpointer, int page_size, int page_no); /*page stuffin here */ void display_page(PAGE VAR_page_displaying); PAGE input_page(void); void read_page(char * strpointer) { FILE *page_write; PAGE page; page_write=fopen("chapter.dat","r"); if(page_write==NULL) { puts("No chapter found!!"); return; } fread(strpointer,sizeof(page),1,page_write); } void display_page(PAGE VAR_page_displaying) { printf("Page number: %d\n\n",VAR_page_displaying.no); printf("Text: %s\n\n",VAR_page_displaying.story); printf("%s press 1\n",VAR_page_displaying.option_1); printf("%s press 2\n",VAR_page_displaying.option_2); } PAGE input_page(void) { PAGE page; printf("\n"); printf("Page no please:"); scanf("%d",&page.no); printf("\n"); printf("Enter text for story\n"); input(page.story, STORY_LENGTH); printf("\n"); printf("Enter text for 1st Option:"); input(page.option_1, OPTION_1_LENGTH); printf(" Enter page link for 1st Option:"); scanf("%d", &page.link_1); printf("\n"); printf("Enter text for 2nd Option:"); input(page.option_2,OPTION_2_LENGTH); printf(" Enter page link for 2nd Option"); scanf("%d", &page.link_2); return(page); } /*must add a function to detect if page has been filled */ void FUNCT_new_page(void) { PAGE VAR_input_page; int done=0; char choice; int pages_done[MAN_ARRAY_SIZE]; int i=0; for(i=0;i #include static FILE *fptr; static int recsize; void open_file(int * pages_done, int array_size); void close_file(int * pages_done, int array_size); void write_file(char * strpointer, int page_size, int page_no); void open_file(int * pages_done, int array_size) { int i=0; if((fptr=fopen("chapter.dat", "r")) !=NULL) { fseek(fptr,0L,SEEK_SET); for(i=0;i