Skip to content

Instantly share code, notes, and snippets.

@mertyildiran
Last active December 15, 2015 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mertyildiran/5191756 to your computer and use it in GitHub Desktop.
Save mertyildiran/5191756 to your computer and use it in GitHub Desktop.
b. Aynı kod üzerinde değişiklikler yaparak (Alıştırma 1' dekine benzer şekilde, “ctype.h” isimli başlık dosyasındaki “islower”, “isupper”, “tolower” ve “toupper” fonksiyonlarından yararlanarak), kaynak dosyadaki tüm büyük karakterleri küçüğe çevirerek kopyalama yapan bir C programı yazınız. Örnek bir kaynak dosya ile bundan üretilen hedef dosya …
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch, source_file[20], target_file[20];
FILE *source, *target;
printf("Enter name of file to copy\n");
gets(source_file);
source = fopen(source_file, "r");
if( source == NULL )
{
printf("Press any key to exit...\n");
exit(EXIT_FAILURE);
}
printf("Enter name of target file\n");
gets(target_file);
target = fopen(target_file, "w");
if( target == NULL )
{
fclose(source);
printf("Press any key to exit...\n");
exit(EXIT_FAILURE);
}
while( ( ch = fgetc(source) ) != EOF )
ch=tolower(ch);
fputc(ch, target);
printf("File copied successfully.\n");
fclose(source);
fclose(target);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment