Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<stdlib.h>
- #include<string.h>
- void wtf() {
- FILE *f = fopen("zborovi.txt", "w");
- char c;
- while((c = getchar()) != EOF) {
- fputc(c, f);
- }
- fclose(f);
- }
- int main() {
- wtf();
- FILE *f;
- if ((f=fopen("zborovi.txt","r"))==NULL) {
- printf("datotekata zborovi,txt ne moze da bide otvorena\n");
- return -1;
- }
- char c;
- char str[100];
- int i;
- int br=0;
- int start,end;
- char newstr[100];
- fscanf(f,"%c",&c);
- while ((fgets(str,100,f))!=NULL) {
- int n=strlen(str);
- i=0;
- while (i<n) {
- if (isalnum(str[i])) {
- start=i;
- while (i<n&&isalnum(str[i])) {
- i++;
- }
- end=i-1;
- if (str[start]==c && str[end]==c) {
- br++;
- strncpy(newstr,str+start,end-start+1);
- printf("%s ",newstr);
- }
- }
- else i++;
- }
- printf("\n");
- }
- printf("%d",br);
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement