![]() |
|
|
#1 (permalink) |
|
Yarbay
![]() ![]() |
Metin Dosyasını Satır Satır Ters Çeviren Program (C)
Açıklama:Bu program komut satırından ismini aldığı bir text dosyasınından yeni bir text dosyası üretmektedir. Yeni üretilen dosya eski dosyanın satırlarının sözcük süzcük ters çevrilmiş biçimidir. Program komut satırından convert biçiminde çalıştırılmalıdır. Ekran Çıktısı:Kaynak dosaya asagidaki gibi olsun LOSING MY RELIGION Life is bigger It's bigger than you And you are not me The lengths that I will go to The distance in your eyes Oh no I've said too much I set it up That's me in the corner That's me in the spotlight Losing my religion Trying to keep up with you And I don't know if I can do it Oh no I've said too much I haven't said enough I thought that I heard you laughing I thought that I heard you sing I think I thought I saw you try Every whisper Of every waking hour I'm Choosing my confessions Trying to keep an eye on you Like a hurt lost and blinded fool Oh no I've said too much I set it up Consider this The hint of the century Consider this The slip that brought me To my knees failed What if all these fantasies Come flailing around Now I've said too much I thought that I heard you laughing I thought that I heard you sing I think I thought I saw you try But that was just a dream That was just a dream Bu dosyadan elde edilecek hedef dosya aşağıdaki gibi olacaktır. RELIGION MY LOSING bigger is Life you than bigger It's me not are you And to go will I that lengths The eyes your in distance The much too said I've no Oh up it set I corner the in me That's spotlight the in me That's religion my Losing you with up keep to Trying it do can I if know don't I And much too said I've no Oh enough said haven't I laughing you heard I that thought I sing you heard I that thought I try you saw I thought I think I whisper Every I'm hour waking every Of confessions my Choosing you on eye an keep to Trying fool blinded and lost hurt a Like much too said I've no Oh up it set I this Consider century the of hint The this Consider me brought that slip The failed knees my To fantasies these all if What around flailing Come much too said I've Now laughing you heard I that thought I sing you heard I that thought I try you saw I thought I think I dream a just was that But dream a just was That Kaynak Kod:#include <stdio.h> #include <string.h> #include <ctype.h> #define MAX_WORD_LEN 50 #define MAX_NAME_LEN 80 #define MAX_LINE_LEN 1000 #define BUFFER_SIZE MAX_LINE_LEN + 1 void revprint(const char *str FILE *fd){ char s[MAX_WORD_LEN + 1] = ""; int index = 0; static const char seps[] = " \n\t .:;!?";while (*str && strchr(seps *str))str++; if (!*str) { return; } while (!strchr(seps *str))s[index++] = *str++; s[index] = '\0'; if (*str == '\0') { fprintf(fd "%s " s);return; } revprint(str fd);fprintf(fd "%s " s);} int main(int argc char **argv){ FILE *fs *fd;char sfname[MAX_NAME_LEN + 1]; char dfname[MAX_NAME_LEN + 1]; char buffer[BUFFER_SIZE]; if (argc != 3) { printf("enter file name to convert : "); gets(sfname); printf("enter new file name : "); gets(dfname); } else { strcpy(sfname argv[1]);strcpy(dfname argv[2]);} fs = fopen(sfname "r");if (fs == aaaa) { fprintf(stderr "cannot open %s!\n" sfname);return 1; } fd = fopen(dfname "w");if (fd == aaaa) { fprintf(stderr "cannot create %s!\n" dfname);fclose(fs); return 2; } while (fgets(buffer BUFFER_SIZE fs)) {revprint(buffer fd);fprintf(fd "\n");} fclose(fs); fclose(fd); return 0; } |
|
|
|
![]() |
| Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir) | |
| Seçenekler | |
| Stil | |
|
|
Benzer Konular
|
||||
| Konu | Konuyu Başlatan | UslanmaM | Cevaplar | Son Mesaj |
| .cue dosyasi olmadan .bin dosyalarini cdye yazmak | ROBERT_DE_NiRO | Resimli Program Açıklamaları | 0 | 08-30-2006 03:58 AM |