Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- int main()
- {
- int postoji = 0;
- FILE* f = fopen("C:\\Users\\Nox Scourge\\Desktop\\recenica.txt", "r");
- if (f == NULL) {
- printf("Fajl \"tekst.txt\" ne postoji u radnom folderu!\n"); //proverava da li fajl postoji
- return 0;
- }
- char rec[50], trenutnaRec[50];
- gets_s(rec); //uzimam recenicu iz fajla
- while (!feof(f)){
- fscanf(f, "%s", trenutnaRec); //unosim koju rec zelim da vidim da li postoji
- if (strcmp(rec, trenutnaRec) == 0) //ako uporedi i vidi da su iste
- postoji = 1; //postoji
- }
- if (postoji) //prikazuje da li postoji ili ne
- printf("Rec postoji fajlu \"tekst.txt\"");
- else
- printf("Rec ne postoji u fajlu \"tekst.txt\"\n");
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement