אחי עשיתי מספר שינויים ויש לי רק טעות אחת#include <stdio.h> #include <string.h> typedef char string; FILE *OpenFile(string path); void GetPath (string path); void CloseFile(FILE *fFile); char *ReadCurrenLN(FILE *fFile); char *ReadCurrenChar(FILE *fFile);
void main(void) { FILE *ptr; string path; char tav; int flag; printf ("enter the file's path"); GetPath(path); while (!feof(ptr) || strcmp(ReadCurrenLN(ptr),"void main(void)")!=0) { ReadCurrenLN(ptr++); } while (flag >= 0) { if(strcmp (ReadCurrenChar(ptr),'{')==0) { flag++; } else if(strcmp(ReadCurrenChar(ptr),'}')==0) { flag--; } tav=fgetc(ptr); printf("%c",tav); ReadCurrenChar(ptr++); } CloseFile(ptr); } FILE *OpenFile(string path) { FILE *ptrOpen = fopen(path,"r"); if (ptrOpen==NULL) { printf("\n Error opening file"); } return ptrOpen; } void GetPath(string path) { printf("enter the file path: "); gets (path); } void CloseFile(FILE *fFile) { fclose(fFile); } char *ReadCurrenLN(FILE *fFile) { string temp; string original; fgets(original,17,fFile); strncpy(temp,originak,15); return temp; } char *ReadCurrenChar(FILE *fFile) { char soger; soger = fgetc(fFile); return soger; }
|