Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void unesi(char niz[], int velicina) {
- char znak = getchar();
- if (znak == '\n') znak = getchar();
- int i = 0;
- while (i < velicina-1 && znak != '\n') {
- niz[i] = znak;
- i++;
- znak = getchar();
- }
- niz[i] = '\0';
- }
- int main(){
- char input[100],output[100];
- printf("Unesite ulaznu datoteku: ");
- unesi(input, sizeof input);
- FILE* open=fopen(input, "r");
- if(open==NULL){
- printf("Daoteka %s ne postoji",input);
- return 1;
- }
- printf("Unesite izlaznu datoteku: ");
- unesi(output, sizeof output);
- FILE* izlaz=fopen(output,"w");
- int c,pozMax,max=0;
- while((c=fgetc(open))!=EOF){
- int poz=ftell(open)-1;
- int slovo=c,brojac=1;
- for(c=fgetc(open);c!=EOF && c==slovo+1;c=fgetc(open),brojac++) slovo=c;
- if(brojac>max) max=brojac,pozMax=poz;
- if(c==EOF)break;
- fseek(open, -1, SEEK_CUR);
- }
- int i;
- fseek(open,pozMax,SEEK_SET);
- for(i=0,c=fgetc(open);i<max && c!=EOF;i++,c=fgetc(open))
- fputc(c,izlaz);
- fclose(open);
- fclose(izlaz);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement