Last active
February 16, 2019 17:52
-
-
Save SirmaXX/dcdd6243fb75aea0d0e6a8cb5c53b883 to your computer and use it in GitHub Desktop.
c language multiple read files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char *argv[]) | |
{ | |
int i; | |
FILE *fp; | |
char str[60]; | |
int k; | |
printf("dosyaların listesi: \n "); | |
for(i=1; i<argc; i++) | |
{ | |
printf("%s\n", argv[i]); | |
fp = fopen( argv[i] , "r"); | |
if(fp == NULL) { | |
printf( "dosya bulunamamaktadır oluşturmak istermisiniz Y(evet),N(hayır) \n:"); | |
scanf("%s %d", str, &k); | |
if(strcmp(str,"Y")==0) { | |
fp = fopen(argv[i], "w+"); | |
fprintf(fp, "deneme...\n"); | |
fputs("deneme...\n", fp); | |
printf("dosyayı oluşturdu"); | |
}else{ | |
perror("Error opening file"); | |
return(-1); | |
} | |
} | |
if(fgets(str, 60, fp)!=NULL ) { | |
puts(str); | |
} | |
fclose(fp); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment