Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int main(int argc, const char * argv[]) {
- if(argc < 3) {
- printf("Vlezna datoteka i izlezna treba da se vnesat kako argument\n");
- return 0;
- }
- FILE *in = fopen(argv[1], "r");
- FILE * out = fopen(argv[2], "w");
- if(in == NULL) {
- printf("Fajlot ne postoi\n");
- return 0;
- }
- if(out == NULL) {
- printf("Fajlot ne postoin\n");
- return 0;
- }
- char s[2000];
- while(fgets(s, 1000, in) != NULL) {
- char zbor[2000];
- int j = 0;
- int brojac = 0;
- for(int i = 0; i < strlen(s); i++) {
- if(isspace(s[i]) && s[i] != '\n') {
- if(brojac == 0) {
- for(int k = 0; k < j; k++) {
- printf("%c", zbor[k]);
- }
- }
- else {
- printf("#");
- for(int k = 0; k < j; k++) {
- printf("%c", zbor[k]);
- }
- }
- j = 0;
- brojac++;
- }
- else if(s[i] == '\n') {
- for(int k = 0; k < j; k++) {
- printf("%c", zbor[k]);
- }
- printf("\n");
- }
- else {
- zbor[j] = s[i];
- j++;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement