Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdlib.h>
- int main(int argc, const char * argv[]) {
- if(argc < 3) {
- printf("Vlezna i izlezna se vnesuvaat kako argumenti\n");
- return 0;
- }
- FILE *in = fopen(argv[1], "r");
- FILE *out = fopen(argv[2], "w");
- if(in == NULL) {
- printf("Ne validna vlezna datoteka\n");
- return 0;
- }
- if(out == NULL) {
- printf("Ne validna izlezna datoteka\n");
- }
- char s[2000];
- while(fgets(s, 1000, in) != NULL) {
- char zbor[2000];
- int j = 0;
- int ok = 1;
- for(int i = 0; i < strlen(s); i++) {
- if(isspace(s[i])) {
- if(tolower(zbor[0]) != tolower(zbor[j - 1])) {
- ok = -1;
- break;
- }
- j = 0;
- }
- else {
- zbor[j] = s[i];
- j++;
- }
- }
- if(ok == 1) {
- fprintf(out, "%s", s);
- }
- }
- return 0;
- }
- /*
- 8
- 1 2 -1 -2 4 3 15 7 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement