My program is running properly if I use the "F7" option in turbo C compiler and execute the code step wise.
But when I use the "RUN" option of turbo C compiler, it keeps running for ever.
Why does such a thing happen?
This is a discussion on doubt within the C Programming forums, part of the General Programming Boards category; My program is running properly if I use the "F7" option in turbo C compiler and execute the code step ...
My program is running properly if I use the "F7" option in turbo C compiler and execute the code step wise.
But when I use the "RUN" option of turbo C compiler, it keeps running for ever.
Why does such a thing happen?
It would appear to me, given the code you posted nicely within [code][/code] tags, that the problem is on line 42.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
I thought the solution was on line 42. Woah, wait a second! I think you're on to something. The answer lies in the problem. The meaning of both the problem and solution in the same line. This getting deep. I think we need to move this thread to the "C Philosophy" forum.
Quzah.
Hope is the first step on the road to disappointment.
sorry, i thought this would be a common problem,
anyway here is the code.
And please tell me, if possible, if i can improve the code with any other special library functions!
Thanks
Code:/*Sequentially read the whole audio book*/ #include "stdio.h" #include "string.h" long global_offset; int count = 0; main() { char *lookinfile, *searchfile, *foundfile; int headercount, i; char *lookforfile(char * , char * , int); clrscr(); for(i=0; i<5; i++) { lookinfile = "0ncc.txt"; searchfile = "smil"; headercount = 1; foundfile = lookforfile(lookinfile, searchfile, headercount); printf("\n%s",foundfile); searchfile = "mp3"; foundfile = lookforfile(foundfile, searchfile, headercount); printf("\n%s",foundfile); } } char *lookforfile(char *lookinfile, char *searchfile, int headercount) { char ch; int j; long offset; FILE *fp; char *lookupfile, *global_next_header, *returnfile; fp = fopen(lookinfile,"r"); lookupfile = "smil"; if(searchfile[0]==lookupfile[0]) { if(count == 0) { while(count != headercount) { /*LOOK FOR headerstring;*/ ch=fgetc(fp); if(ch=='<') { if((ch=fgetc(fp))=='h') { if((ch=fgetc(fp))=='1') { /*FOUND H1?*/ count = count+1; } } } } } if(count>1) { fseek(fp, global_offset, SEEK_SET); } while(ch!='\n') { /*Look for h ref="......"*/ /*... *lookupfile = "xyz.smil" */ if((ch=fgetc(fp))=='h') { if((ch=fgetc(fp))=='r') { if((ch=fgetc(fp))=='e') { if((ch=fgetc(fp))=='f') { if((ch=fgetc(fp))=='\=') { if((ch=fgetc(fp))=='\"') { j=0; while((ch=fgetc(fp))!='\#') { returnfile[j]=ch; j++; } returnfile[j]='\0'; } } } } } } } /*WHAT IS NEXT AVAILABLE HEADER?*/ while((ch=getc(fp))!='\<'); j=0; while((ch=getc(fp))!='\ ') { global_next_header[j]=ch; j++; } count = count+1; global_offset = ftell(fp); global_next_header[j]='\0'; return(returnfile); } lookupfile="mp3"; /*LOOK UP MP3 FILE */ if(searchfile[0]==lookupfile[0]) { /*Look for audio src"......"*/ /*...*lookupfile = "abc.mp3"...*/ while((ch=fgetc(fp))!='\n') { if(ch=='s') { if((ch=fgetc(fp))=='r') { if((ch=fgetc(fp))=='c') { if((ch=fgetc(fp))=='\=') { if((ch=fgetc(fp))=='\"') { j=0; while((ch=fgetc(fp))!='\"') { returnfile[j]=ch; j++; } returnfile[j]='\0'; } } } } } } return(returnfile); } }